Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/jekyll/filters/url_filters.rb
Expand Up @@ -10,6 +10,7 @@ module URLFilters
# 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
Expand Down
5 changes: 5 additions & 0 deletions test/test_filters.rb
Expand Up @@ -404,6 +404,11 @@ def select; end
})
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
Expand Down