From d929242e2b3db510ff4d23d7c0ef7daa83ab1cb6 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 19 Feb 2016 15:00:28 -0800 Subject: [PATCH] Permalinks which end in a slash should always output HTML Duplicates #4493 for 3.1.1. /cc @jekyll/core --- lib/jekyll/document.rb | 7 +++++-- test/source/_with.dots/mit.txt | 4 ++++ test/source/contacts/humans.txt | 5 +++++ test/test_collections.rb | 2 +- test/test_filters.rb | 2 +- test/test_site.rb | 1 + 6 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 test/source/_with.dots/mit.txt create mode 100644 test/source/contacts/humans.txt diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index fc3633d8..10f1203e 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -217,8 +217,11 @@ module Jekyll def destination(base_directory) dest = site.in_dest_dir(base_directory) path = site.in_dest_dir(dest, URL.unescape_path(url)) - path = File.join(path, "index.html") if url.end_with?("/") - path << output_ext unless path.end_with? output_ext + if url.end_with? "/" + path = File.join(path, "index.html") + else + path << output_ext unless path.end_with? output_ext + end path end diff --git a/test/source/_with.dots/mit.txt b/test/source/_with.dots/mit.txt new file mode 100644 index 00000000..c366b0df --- /dev/null +++ b/test/source/_with.dots/mit.txt @@ -0,0 +1,4 @@ +--- +--- + +I should be output to `/with.dots/mit/index.html`. diff --git a/test/source/contacts/humans.txt b/test/source/contacts/humans.txt new file mode 100644 index 00000000..84e2982b --- /dev/null +++ b/test/source/contacts/humans.txt @@ -0,0 +1,5 @@ +--- +permalink: /contacts/humans/ +--- + +I should be output to `/contacts/humans/index.html`. diff --git a/test/test_collections.rb b/test/test_collections.rb index 138bed6b..d6d7d7de 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -203,7 +203,7 @@ class TestCollections < JekyllUnitTest end should "contain one document" do - assert_equal 3, @collection.docs.size + assert_equal 4, @collection.docs.size end should "allow dots in the filename" do diff --git a/test/test_filters.rb b/test/test_filters.rb index ca7cd49d..e9035b96 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -285,7 +285,7 @@ class TestFilters < JekyllUnitTest assert_equal 2, g["items"].size when "" assert g["items"].is_a?(Array), "The list of grouped items for '' is not an Array." - assert_equal 12, g["items"].size + assert_equal 13, g["items"].size end end end diff --git a/test/test_site.rb b/test/test_site.rb index c06c218e..3bb93c35 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -178,6 +178,7 @@ class TestSite < JekyllUnitTest environment.html exploit.md foo.md + humans.txt index.html index.html main.scss