Merge pull request #1655 from mojavelinux/issue-1653

resolves #1653 don't rewrite paths that start with //
This commit is contained in:
Thomas Reynolds 2015-10-26 10:21:11 -07:00
commit 30e37293b3
3 changed files with 7 additions and 3 deletions

View file

@ -11,6 +11,7 @@ Feature: Alternate between multiple asset hosts
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"' Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
Then I should see content matching %r{http://assets1.example.com/} Then I should see content matching %r{http://assets1.example.com/}
Then I should not see content matching %r{http://assets1.example.com//} Then I should not see content matching %r{http://assets1.example.com//}
Then I should see content matching %r{'//www.example.com/script.js'}
When I go to "/stylesheets/asset_host.css" When I go to "/stylesheets/asset_host.css"
Then I should see content matching %r{http://assets1.example.com/} Then I should see content matching %r{http://assets1.example.com/}
Then I should not see content matching %r{http://assets1.example.com//} Then I should not see content matching %r{http://assets1.example.com//}
@ -28,6 +29,7 @@ Feature: Alternate between multiple asset hosts
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"' Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
Then I should see content matching %r{http://assets1.example.com/} Then I should see content matching %r{http://assets1.example.com/}
Then I should not see content matching %r{http://assets1.example.com//} Then I should not see content matching %r{http://assets1.example.com//}
Then I should see content matching %r{'//www.example.com/script.js'}
When I go to "/stylesheets/asset_host.css" When I go to "/stylesheets/asset_host.css"
Then I should see content matching %r{http://assets1.example.com/} Then I should see content matching %r{http://assets1.example.com/}
Then I should not see content matching %r{http://assets1.example.com//} Then I should not see content matching %r{http://assets1.example.com//}

View file

@ -39,4 +39,6 @@
<%= image_tag "blank1031.gif" %> <%= image_tag "blank1031.gif" %>
<%= image_tag "blank1032.gif" %> <%= image_tag "blank1032.gif" %>
<%= image_tag "blank1033.gif" %> <%= image_tag "blank1033.gif" %>
<%= image_tag "blank1034.gif" %> <%= image_tag "blank1034.gif" %>
<script>(function(a,b,c,d){})(window,document,'script','//www.example.com/script.js');</script>

View file

@ -333,7 +333,7 @@ module Middleman
asset_path = $2 asset_path = $2
uri = ::Addressable::URI.parse(asset_path) uri = ::Addressable::URI.parse(asset_path)
if uri.relative? && result = yield(asset_path) if uri.relative? && uri.host.nil? && (result = yield(asset_path))
"#{opening_character}#{result}" "#{opening_character}#{result}"
else else
match match