lib/action_view/template/resolver.rb in actionpack-3.2.18 vs lib/action_view/template/resolver.rb in actionpack-3.2.19

- old
+ new

@@ -118,26 +118,40 @@ end def query(path, details, formats) query = build_query(path, details) - # deals with case-insensitive file systems. - sanitizer = Hash.new { |h,dir| h[dir] = Dir["#{dir}/*"] } + template_paths = find_template_paths query - template_paths = Dir[query].reject { |filename| - File.directory?(filename) || - !sanitizer[File.dirname(filename)].include?(filename) - } - template_paths.map { |template| handler, format = extract_handler_and_format(template, formats) contents = File.binread template Template.new(contents, File.expand_path(template), handler, :virtual_path => path.virtual, :format => format, :updated_at => mtime(template)) } + end + + if RUBY_VERSION >= '2.2.0' + def find_template_paths(query) + Dir[query].reject { |filename| + File.directory?(filename) || + # deals with case-insensitive file systems. + !File.fnmatch(query, filename, File::FNM_EXTGLOB) + } + end + else + def find_template_paths(query) + # deals with case-insensitive file systems. + sanitizer = Hash.new { |h,dir| h[dir] = Dir["#{dir}/*"] } + + Dir[query].reject { |filename| + File.directory?(filename) || + !sanitizer[File.dirname(filename)].include?(filename) + } + end end # Helper for building query glob string based on resolver's pattern. def build_query(path, details) query = @pattern.dup