This commit is contained in:
Parker Moore 2014-10-22 02:16:50 -07:00
parent 5cb0aee251
commit ae01b1d5df
2 changed files with 8 additions and 1 deletions

View File

@ -47,7 +47,7 @@ module Jekyll
def generate_url
@placeholders.inject(@template) do |result, token|
break result if result.index(':').nil?
result.gsub(':#{token.first}', self.class.escape_path(token.last))
result.gsub(/:#{token.first}/, self.class.escape_path(token.last))
end
end

View File

@ -16,6 +16,13 @@ class TestURL < Test::Unit::TestCase
).to_s
end
should "handle multiple of the same key in the template" do
assert_equal '/foo/bar/foo/', URL.new(
:template => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"}
).to_s
end
should "return permalink if given" do
assert_equal "/le/perma/link", URL.new(
:template => "/:x/:y",