Skip to content
Browse files

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.
  • Loading branch information...
1 parent 4090500 commit 441eddf1caf9905aa1a909a229c2045832da000b @fotos committed
Showing with 15 additions and 4 deletions.
  1. +8 −2 lib/jekyll/page.rb
  2. +7 −2 test/test_page.rb
View
10 lib/jekyll/page.rb
@@ -45,8 +45,14 @@ def permalink
#
# 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
View
9 test/test_page.rb
@@ -64,8 +64,13 @@ def do_render(page)
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 @@ def do_render(page)
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

0 comments on commit 441eddf

Please sign in to comment.
Something went wrong with that request. Please try again.