Guard against type error in absolute url (#6280)
Merge pull request 6280
This commit is contained in:
parent
29b96f4408
commit
045226f160
|
@ -12,9 +12,9 @@ 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?
|
||||
return input if Addressable::URI.parse(input.to_s).absolute?
|
||||
site = @context.registers[:site]
|
||||
return relative_url(input).to_s if site.config["url"].nil?
|
||||
return relative_url(input) if site.config["url"].nil?
|
||||
Addressable::URI.parse(
|
||||
site.config["url"].to_s + relative_url(input)
|
||||
).normalize.to_s
|
||||
|
|
|
@ -440,6 +440,10 @@ class TestFilters < JekyllUnitTest
|
|||
filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) })
|
||||
assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url)
|
||||
end
|
||||
|
||||
should "not raise a TypeError when passed a hash" do
|
||||
assert @filter.absolute_url({ "foo" => "bar" })
|
||||
end
|
||||
end
|
||||
|
||||
context "relative_url filter" do
|
||||
|
|
Loading…
Reference in New Issue