diff --git a/features/post_url_tag.feature b/features/post_url_tag.feature index 172f914db..ee59b71c7 100644 --- a/features/post_url_tag.feature +++ b/features/post_url_tag.feature @@ -132,3 +132,28 @@ Feature: PostUrl Tag And I should see "Deprecation: A call to '{% post_url 2019-02-04-hello-world %}' did not match a post" in the build output But the _site directory should exist And I should see "
" in "_site/index.html" + + Scenario: Nested posts in a directory with name containing spaces + Given I have a Cats and Dogs/_posts directory + And I have the following post in "Cats and Dogs": + | title | date | content | + | Hello World | 2019-02-04 | Lorem ipsum dolor | + And I have a _posts/Salt and Pepper directory + And I have the following post under "Salt and Pepper": + | title | date | content | + | Hello Again | 2019-02-05 | Lorem ipsum dolor | + And I have an "index.md" file with content: + """ + --- + --- + + [Post 1]({% post_url Cats and Dogs/2019-02-04-hello-world %}) + + [Post 2]({% post_url Salt and Pepper/2019-02-05-hello-again %}) + """ + When I run jekyll build + Then I should get a zero exit status + And I should not see "Deprecation: A call to '{% post_url" in the build output + But the _site directory should exist + And I should see "" in "_site/index.html" + And I should see "" in "_site/index.html" diff --git a/features/support/helpers.rb b/features/support/helpers.rb index db36141d3..b6e77eec4 100644 --- a/features/support/helpers.rb +++ b/features/support/helpers.rb @@ -127,7 +127,7 @@ def location(folder, direction) end [before || ".", - after || ".",] + after || "",] end # diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 039ab4f48..874dd6439 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -16,9 +16,8 @@ module Jekyll "'#{name}' does not contain valid date and/or title." end - escaped_slug = Regexp.escape(slug) - @name_regex = %r!^_posts/#{path}#{date}-#{escaped_slug}\.[^.]+| - ^#{path}_posts/?#{date}-#{escaped_slug}\.[^.]+!x + basename_pattern = "#{date}-#{Regexp.escape(slug)}\\.[^.]+" + @name_regex = %r!^_posts/#{path}#{basename_pattern}|^#{path}_posts/?#{basename_pattern}! end def post_date