Use Addressable to improve inline url detection and rewriting. Only rewrite relative paths. Closes #1499
This commit is contained in:
parent
40e01b0b21
commit
4740159a3a
3 changed files with 14 additions and 16 deletions
|
@ -15,6 +15,7 @@ require 'rack/mime'
|
|||
require 'middleman-core/contracts'
|
||||
|
||||
# For URI templating
|
||||
require 'addressable/uri'
|
||||
require 'addressable/template'
|
||||
require 'active_support/inflector'
|
||||
require 'active_support/inflector/transliterate'
|
||||
|
@ -323,9 +324,15 @@ module Middleman
|
|||
opening_character = $1
|
||||
asset_path = $2
|
||||
|
||||
if result = yield(asset_path)
|
||||
"#{opening_character}#{result}"
|
||||
else
|
||||
begin
|
||||
uri = ::Addressable::URI.parse(asset_path)
|
||||
|
||||
if uri.relative? && result = yield(asset_path)
|
||||
"#{opening_character}#{result}"
|
||||
else
|
||||
match
|
||||
end
|
||||
rescue
|
||||
match
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue