mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-30 01:08:26 -05:00
Ensure leading slashes in path matching.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user