From 95b7f66ad5c6feaa74e17ac0936ce57f63c1cbe7 Mon Sep 17 00:00:00 2001 From: Sergey Kojin Date: Sun, 20 Feb 2011 13:38:23 +0300 Subject: [PATCH] assert_host should be ignored on protocol relative url --- .../helpers/asset_tag_helpers/asset_paths.rb | 2 +- actionpack/test/template/asset_tag_helper_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb index 014a03c..b484c01 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb @@ -52,7 +52,7 @@ module ActionView end def is_uri?(path) - path =~ %r{^[-a-z]+://|^cid:} + path =~ %r{^([-a-z]+:)?//|^cid:} end private diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index a1a6b5f..7869386 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -1099,6 +1099,13 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase @controller.config.asset_host = "http://assets.example.com" assert_dom_equal(%(), stylesheet_link_tag("http://bar.example.com/stylesheets/style.css")) end + + def test_should_ignore_asset_host_on_protocol_relative_url + # According to http://labs.apache.org/webarch/uri/rfc/rfc3986.html#relative-ref, example http://labs.apache.org/webarch/uri/rfc/rfc3986.html#relative-normal + @controller.config.asset_host = "http://assets.example.com" + assert_dom_equal(%(), stylesheet_link_tag("//bar.example.com/stylesheets/style.css")) + end + def test_should_wildcard_asset_host_between_zero_and_four @controller.config.asset_host = 'http://a%d.example.com' -- 1.7.2.3