Ensure leading slashes in path matching.
This commit is contained in:
parent
42fc5e9ee7
commit
35868807c1
|
@ -55,9 +55,19 @@ class Hash
|
|||
end
|
||||
|
||||
module Enumerable
|
||||
def ensure_leading_slash(path)
|
||||
path[0..0] == "/" ? path : "/#{path}"
|
||||
end
|
||||
|
||||
# Returns true if path matches against any glob pattern.
|
||||
# Look for more detail about glob pattern in method File::fnmatch.
|
||||
def glob_include?(e)
|
||||
any? { |exp| File.fnmatch?(exp, e) }
|
||||
entry = ensure_leading_slash(e)
|
||||
any? do |exp|
|
||||
item = ensure_leading_slash(exp)
|
||||
Jekyll.logger.debug "glob_include?(#{entry})"
|
||||
Jekyll.logger.debug " ==> File.fnmatch?(#{item}, #{entry}) == #{File.fnmatch?(item, entry)}"
|
||||
File.fnmatch?(item, entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue