absolute_url should not mangle URL if called more than once (#5789)

Merge pull request 5789
This commit is contained in:
jekyllbot 2017-04-05 16:16:55 -04:00 committed by GitHub
parent f46dffcc8e
commit 768d2bb5a3
2 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@ module Jekyll
# Returns the absolute URL as a String.
def absolute_url(input)
return if input.nil?
return input if Addressable::URI.parse(input).absolute?
site = @context.registers[:site]
return relative_url(input).to_s if site.config["url"].nil?
Addressable::URI.parse(site.config["url"] + relative_url(input)).normalize.to_s

View File

@ -402,6 +402,11 @@ class TestFilters < JekyllUnitTest
})
assert_equal "http://xn--mlaut-jva.example.org/", filter.absolute_url(page_url)
end
should "not modify an absolute URL" do
page_url = "http://example.com/"
assert_equal "http://example.com/", @filter.absolute_url(page_url)
end
end
context "relative_url filter" do