Skip to content

Commit

Permalink
Config include trailing slash (#8113)
Browse files Browse the repository at this point in the history
Merge pull request 8113
  • Loading branch information
billykong committed Apr 27, 2020
1 parent 82f1b32 commit 7087032
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/jekyll/entry_filter.rb
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.
Empty file.
7 changes: 7 additions & 0 deletions test/test_entry_filter.rb
Expand Up @@ -149,5 +149,12 @@ 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/_is_dir/", "_glob_include_test/_not_dir/"]
assert @filter.glob_include?(data, "_glob_include_test/_is_dir")
assert @filter.glob_include?(data, "_glob_include_test/_is_dir/include_me.txt")
refute @filter.glob_include?(data, "_glob_include_test/_not_dir")
end
end
end

0 comments on commit 7087032

Please sign in to comment.