Fix empty host for an asset url when asset_host proc returns nil #16161

Merged
merged 1 commit into from Jul 15, 2014

Conversation

Projects
None yet
3 participants
@jpawlyn
Contributor

jpawlyn commented Jul 14, 2014

If a CDN can be dynamically enabled in an app, when it is switched off and the asset_host proc returns nil, all asset urls are relative instead of absolute. This fix makes the urls absolute.

@matthewd

This comment has been minimized.

Show comment
Hide comment
@matthewd

matthewd Jul 14, 2014

Member

Per @pixeltrix's comment, please also assert that asset_path looks right here. (Though at a glance, it sounds like it will.)

Member

matthewd commented Jul 14, 2014

Per @pixeltrix's comment, please also assert that asset_path looks right here. (Though at a glance, it sounds like it will.)

@jpawlyn

This comment has been minimized.

Show comment
Hide comment
@jpawlyn

jpawlyn Jul 14, 2014

Contributor

Is this looking better or have I misunderstood?

Contributor

jpawlyn commented Jul 14, 2014

Is this looking better or have I misunderstood?

+ @controller.config.asset_host = Proc.new { nil }
+ @controller.request = Struct.new(:base_url, :script_name).new("http://www.example.com", nil)
+
+ assert_equal "/foo", asset_path("foo")

This comment has been minimized.

@matthewd

matthewd Jul 14, 2014

Member
assert_equal "/images/rails.png", image_path("rails.png")

.. just as a direct contrast to image_url, because the other similar test that I saw doesn't set up base_url.

@matthewd

matthewd Jul 14, 2014

Member
assert_equal "/images/rails.png", image_path("rails.png")

.. just as a direct contrast to image_url, because the other similar test that I saw doesn't set up base_url.

@jpawlyn

This comment has been minimized.

Show comment
Hide comment
@jpawlyn

jpawlyn Jul 14, 2014

Contributor

Cool, makes sense

Contributor

jpawlyn commented Jul 14, 2014

Cool, makes sense

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Jul 15, 2014

Member

@jpawlyn can you squash your commits and add an entry to CHANGELOG - thanks.

Member

pixeltrix commented Jul 15, 2014

@jpawlyn can you squash your commits and add an entry to CHANGELOG - thanks.

@jpawlyn

This comment has been minimized.

Show comment
Hide comment
@jpawlyn

jpawlyn Jul 15, 2014

Contributor

@pixeltrix All done

Contributor

jpawlyn commented Jul 15, 2014

@pixeltrix All done

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Jul 15, 2014

Member

@jpawlyn okay, thanks - just waiting on the CI and then I'll do the backports to 4-1-stable and 4-0-stable.

Member

pixeltrix commented Jul 15, 2014

@jpawlyn okay, thanks - just waiting on the CI and then I'll do the backports to 4-1-stable and 4-0-stable.

pixeltrix added a commit that referenced this pull request Jul 15, 2014

Merge pull request #16161 from jpawlyn/master
Fix empty host for an asset url when asset_host proc returns nil

@pixeltrix pixeltrix merged commit c3f4d6c into rails:master Jul 15, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Jul 15, 2014

Member

Backported to 4-1-stable (08e528d) and 4-0-stable (0997ceb)

Member

pixeltrix commented Jul 15, 2014

Backported to 4-1-stable (08e528d) and 4-0-stable (0997ceb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment