From 441eddf1caf9905aa1a909a229c2045832da000b Mon Sep 17 00:00:00 2001 From: Fotos Georgiadis Date: Thu, 28 Feb 2013 03:49:39 +0200 Subject: [PATCH] Fix pretty url style paths. Ignore the basename if the page is an index page, preserve it if it's just an html page and use the full path in every other case. --- lib/jekyll/page.rb | 10 ++++++++-- test/test_page.rb | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index faf340b8..b20bee22 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -45,8 +45,14 @@ module Jekyll # # Returns the template String. def template - if self.site.permalink_style == :pretty && !index? && html? - "/:path/:basename/" + if self.site.permalink_style == :pretty + if index? && html? + "/:path/" + elsif html? + "/:path/:basename/" + else + "/:path/:basename:output_ext" + end else "/:path/:basename:output_ext" end diff --git a/test/test_page.rb b/test/test_page.rb index 6d4bef2a..8d13cda7 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -64,8 +64,13 @@ class TestPage < Test::Unit::TestCase context "in a directory hierarchy" do should "create url based on filename" do + @page = setup_page('/contacts', 'bar.html') + assert_equal "/contacts/bar/", @page.url + end + + should "create index url based on filename" do @page = setup_page('/contacts', 'index.html') - assert_equal "/contacts/index.html", @page.url + assert_equal "/contacts/", @page.url end should "return dir correctly" do @@ -75,7 +80,7 @@ class TestPage < Test::Unit::TestCase should "return dir correctly for index page" do @page = setup_page('/contacts', 'index.html') - assert_equal '/contacts', @page.dir + assert_equal '/contacts/', @page.dir end end end