Use regexp to filter special entries (#7702)

Merge pull request 7702
This commit is contained in:
Ashwin Maroli 2019-06-24 01:53:09 +05:30 committed by jekyllbot
parent e37ee47219
commit 06eafadcbb
1 changed files with 3 additions and 5 deletions

View File

@ -3,9 +3,7 @@
module Jekyll module Jekyll
class EntryFilter class EntryFilter
attr_reader :site attr_reader :site
SPECIAL_LEADING_CHARACTERS = [ SPECIAL_LEADING_CHAR_REGEX = %r!\A#{Regexp.union([".", "_", "#", "~"])}!o.freeze
".", "_", "#", "~",
].freeze
def initialize(site, base_directory = nil) def initialize(site, base_directory = nil)
@site = site @site = site
@ -50,8 +48,8 @@ module Jekyll
end end
def special?(entry) def special?(entry)
SPECIAL_LEADING_CHARACTERS.include?(entry[0..0]) || SPECIAL_LEADING_CHAR_REGEX.match?(entry) ||
SPECIAL_LEADING_CHARACTERS.include?(File.basename(entry)[0..0]) SPECIAL_LEADING_CHAR_REGEX.match?(File.basename(entry))
end end
def backup?(entry) def backup?(entry)