Config include trailing slash (#8113)

Merge pull request 8113
This commit is contained in:
Billy Kong 2020-04-27 22:06:05 +08:00 committed by GitHub
parent 82f1b32896
commit 70870328bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

View File

@ -98,7 +98,8 @@ module Jekyll
pattern_with_source = PathManager.join(site.source, pattern) pattern_with_source = PathManager.join(site.source, pattern)
File.fnmatch?(pattern_with_source, entry_with_source) || 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 when Regexp
pattern.match?(entry_with_source) pattern.match?(entry_with_source)
else else

View File

View File

@ -149,5 +149,12 @@ class TestEntryFilter < JekyllUnitTest
assert @filter.glob_include?(data, "vendor/bundle/jekyll/lib/page.rb") assert @filter.glob_include?(data, "vendor/bundle/jekyll/lib/page.rb")
assert @filter.glob_include?(data, "/vendor/ruby/lib/set.rb") assert @filter.glob_include?(data, "/vendor/ruby/lib/set.rb")
end 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
end end