Leonid Shevtsov
Leonid Shevtsov

Reputation: 14179

Weird asset url without 'http' in Rails 3.1

I'm using Rails 3.1.1, Ruby 1.9.3, asset_host='assets.foo.com'

This

<%= stylesheet_link_tag 'home' %>
<%= javascript_include_tag 'home' %>

produces

<link href="http://assets.foo.com/assets/home-f803345a3514568545f88946a69d6bab.css" media="screen" rel="stylesheet" type="text/css" />

<script src="//assets.foo.com/assets/home-da846573d17e8a062b5a8d6c122abc97.js" type="text/javascript"></script>

I can't figure out why the script's src is malformed.

I see similar URLs without the protocol schema in CSS file, as the result of the image-url() Sass helper.

Where should I look to resolve this?

Upvotes: 0

Views: 346

Answers (1)

smoak
smoak

Reputation: 15024

It's not malformed. Most modern browsers these days will automatically put in the protocol you're using when it sees the //. It's called relative protocol resolution.

See this answer as well as RFC 3986 Section 5.2

Upvotes: 4

Related Questions