This project is archived and is in readonly mode.

#6748 new
Chad K

Asset helpers should understand scheme-relative URLs

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

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...

No comments found

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages