From 35868807c19c171e6c34fda97605fed2022fabdf Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 5 Jan 2014 10:54:52 -0800 Subject: [PATCH] Ensure leading slashes in path matching. --- lib/jekyll/core_ext.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/core_ext.rb b/lib/jekyll/core_ext.rb index ce74d2ba..dd9af277 100644 --- a/lib/jekyll/core_ext.rb +++ b/lib/jekyll/core_ext.rb @@ -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