Skip to content

Commit

Permalink
Backport memoize-document-url from #6266 to 3.5-stable [merge conflicts]
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter authored and parkr committed Aug 12, 2017
1 parent 0ef2937 commit a564b23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jekyll/filters/url_filters.rb
Expand Up @@ -12,7 +12,7 @@ def absolute_url(input)
return if input.nil?
return input if Addressable::URI.parse(input.to_s).absolute?
site = @context.registers[:site]
return relative_url(input) if site.config["url"].nil?
return relative_url(input).to_s if site.config["url"].nil?
Addressable::URI.parse(
site.config["url"].to_s + relative_url(input)
).normalize.to_s
Expand Down
16 changes: 16 additions & 0 deletions test/test_filters.rb
Expand Up @@ -13,6 +13,16 @@ def initialize(opts = {})
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 = {})
JekyllFilter.new(site_configuration(opts)).tap do |f|
tz = f.site.config["timezone"]
Expand Down Expand Up @@ -510,6 +520,12 @@ def select; end
url << "foo"
assert_equal "/front_matter.erb", page.url
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

context "strip_index filter" do
Expand Down

0 comments on commit a564b23

Please sign in to comment.