From 1356e75811db42f5aa9596cf73acc8ec38ea1a3c Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Sun, 10 Jul 2011 23:56:51 +0200 Subject: [PATCH] Generate escaped url for categories with space. Space in URLs should be encoded. Signed-off-by: Laurent Arnoud --- lib/jekyll/post.rb | 2 +- test/test_post.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 5502994ceac..bafb72573b0 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -131,7 +131,7 @@ def url "title" => CGI.escape(slug), "i_day" => date.strftime("%d").to_i.to_s, "i_month" => date.strftime("%m").to_i.to_s, - "categories" => categories.join('/'), + "categories" => categories.map {|c| URI.escape(c) }.join('/'), "output_ext" => self.output_ext }.inject(template) { |result, token| result.gsub(/:#{Regexp.escape token.first}/, token.last) diff --git a/test/test_post.rb b/test/test_post.rb index 1c3ea6419e5..245c30b4c45 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -141,6 +141,19 @@ def do_render(post) end end + context "with space (categories)" do + setup do + @post.categories << "French cuisine" + @post.categories << "Belgian beer" + @post.process(@fake_file) + end + + should "process the url correctly" do + assert_equal "/:categories/:year/:month/:day/:title.html", @post.template + assert_equal "/French%20cuisine/Belgian%20beer/2008/09/09/foo-bar.html", @post.url + end + end + context "with none style" do setup do @post.site.permalink_style = :none