Skip to content

Commit

Permalink
Handle include directory with trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
billykong committed Apr 12, 2020
1 parent ffdab93 commit d2b639e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/jekyll/entry_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def glob_include?(enumerator, entry)
pattern_with_source = PathManager.join(site.source, pattern)

File.fnmatch?(pattern_with_source, entry_with_source) ||
entry_with_source.start_with?(pattern_with_source)
entry_with_source.start_with?(pattern_with_source) ||
(pattern_with_source == "#{entry_with_source}/" if File.directory?(entry_with_source))
when Regexp
pattern.match?(entry_with_source)
else
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions test/test_entry_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,13 @@ class TestEntryFilter < JekyllUnitTest
assert @filter.glob_include?(data, "vendor/bundle/jekyll/lib/page.rb")
assert @filter.glob_include?(data, "/vendor/ruby/lib/set.rb")
end

should "match directory only if there is trailing slash" do
data = ["../_glob_include_test/", "_not_dir/"]
assert @filter.glob_include?(data, "../_glob_include_test")
assert @filter.glob_include?(data, "../_glob_include_test/include_me.txt")
assert !@filter.glob_include?(data, "../_not_dir")
end

end
end

0 comments on commit d2b639e

Please sign in to comment.