Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

feature detect for FNM_EXTGLOB for older Ruby. Fixes #15053

  • Loading branch information...
commit 68d21284e7a89f50e2ffb6dddadbd7bb993a10ca 1 parent 6901012
@tenderlove tenderlove authored
Showing with 21 additions and 5 deletions.
  1. +21 −5 actionpack/lib/action_view/template/resolver.rb
View
26 actionpack/lib/action_view/template/resolver.rb
@@ -180,11 +180,7 @@ def find_templates(name, prefix, partial, details)
def query(path, details, formats)
query = build_query(path, details)
- template_paths = Dir[query].reject { |filename|
- File.directory?(filename) ||
- # deals with case-insensitive file systems.
- !File.fnmatch(query, filename, File::FNM_EXTGLOB)
- }
+ template_paths = find_template_paths query
template_paths.map { |template|
handler, format = extract_handler_and_format(template, formats)
@@ -197,6 +193,26 @@ def query(path, details, formats)
}
end
+ if File.const_defined? :FNM_EXTGLOB
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.