Ensure leading slashes in path matching.

This commit is contained in:
Parker Moore 2014-01-05 10:54:52 -08:00
parent 42fc5e9ee7
commit 35868807c1
1 changed files with 11 additions and 1 deletions

View File

@ -55,9 +55,19 @@ class Hash
end end
module Enumerable module Enumerable
def ensure_leading_slash(path)
path[0..0] == "/" ? path : "/#{path}"
end
# Returns true if path matches against any glob pattern. # Returns true if path matches against any glob pattern.
# Look for more detail about glob pattern in method File::fnmatch. # Look for more detail about glob pattern in method File::fnmatch.
def glob_include?(e) 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
end end