Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Asset helpers should understand scheme-relative URLs

#6748

If you have this configuration:

ActionController::Base.asset_host = "assets.example.com"

And do this:

image_tag("//mysite.com/images/image.png")

You get something like:

<img src="http://assets.example.com//mysite.com/images/image.png" >

When instead this should be rendered:

<img src="//mysite.com/images/image.png" >

Which allows the browser to resolve the URL relative the current scheme, e.g. http, https.

An example of this case can be seen in the URI spec here:

http://labs.apache.org/webarch/uri/rfc/rfc3986.html#relative-normal

Ex:

"//g" => "http://g"

assuming the current scheme is http.

I've attached a patch to actionpack to support scheme-relative URL's in asset helpers.

Github commit can be seen here:

https://github.com/chadk/rails/commit/61eae0f2b1bfcb54f0355b710808b...

Reported by Chad K · April 26th, 2011 @ 06:17 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

No comments yet.