From 0df00d907982035bd74464720e7f8190a70dbcee Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 18 Aug 2011 02:59:02 -0700 Subject: [PATCH] minor details revised in a gsub Regexps have a construct to express alternation of characters, which is character classes. In addition to being the most specific idiom to write this pattern, it reads better without the backslashes. Also, it is better not to use a capture if none is needed. As a side-effect of these changes, the gsub is marginally faster, but speed is not the point of this commit. --- actionpack/lib/action_view/template/resolver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index f1916a1a3f75b..b644890f145ce 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -164,7 +164,7 @@ def build_query(path, details) end def escape_entry(entry) - entry.gsub(/(\*|\[|\]|\{|\}|\?)/, "\\\\\\1") + entry.gsub(/[*?{}\[\]]/, '\\\\\\&') end # Returns the file mtime from the filesystem.