Call to_s on site.url before attempting to concatenate strings (#6253)
Merge pull request 6253
This commit is contained in:
parent
a6efa48883
commit
b35c0d8607
|
@ -13,7 +13,9 @@ module Jekyll
|
||||||
return input if Addressable::URI.parse(input).absolute?
|
return input if Addressable::URI.parse(input).absolute?
|
||||||
site = @context.registers[:site]
|
site = @context.registers[:site]
|
||||||
return relative_url(input).to_s if site.config["url"].nil?
|
return relative_url(input).to_s if site.config["url"].nil?
|
||||||
Addressable::URI.parse(site.config["url"] + relative_url(input)).normalize.to_s
|
Addressable::URI.parse(
|
||||||
|
site.config["url"].to_s + relative_url(input)
|
||||||
|
).normalize.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces a URL relative to the domain root based on site.baseurl.
|
# Produces a URL relative to the domain root based on site.baseurl.
|
||||||
|
|
|
@ -13,6 +13,16 @@ class TestFilters < JekyllUnitTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Value
|
||||||
|
def initialize(value)
|
||||||
|
@value = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
@value.respond_to?(:call) ? @value.call : @value.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def make_filter_mock(opts = {})
|
def make_filter_mock(opts = {})
|
||||||
JekyllFilter.new(site_configuration(opts)).tap do |f|
|
JekyllFilter.new(site_configuration(opts)).tap do |f|
|
||||||
tz = f.site.config["timezone"]
|
tz = f.site.config["timezone"]
|
||||||
|
@ -423,6 +433,12 @@ class TestFilters < JekyllUnitTest
|
||||||
page_url = "http://example.com/"
|
page_url = "http://example.com/"
|
||||||
assert_equal "http://example.com/", @filter.absolute_url(page_url)
|
assert_equal "http://example.com/", @filter.absolute_url(page_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "transform the input URL to a string" do
|
||||||
|
page_url = "/my-page.html"
|
||||||
|
filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) })
|
||||||
|
assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "relative_url filter" do
|
context "relative_url filter" do
|
||||||
|
@ -500,6 +516,12 @@ class TestFilters < JekyllUnitTest
|
||||||
url << "foo"
|
url << "foo"
|
||||||
assert_equal "/front_matter.erb", page.url
|
assert_equal "/front_matter.erb", page.url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "transform the input baseurl to a string" do
|
||||||
|
page_url = "/my-page.html"
|
||||||
|
filter = make_filter_mock({ "baseurl" => Value.new(proc { "/baseurl/" }) })
|
||||||
|
assert_equal "/baseurl#{page_url}", filter.relative_url(page_url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "strip_index filter" do
|
context "strip_index filter" do
|
||||||
|
|
Loading…
Reference in New Issue