Browse files

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.
  • Loading branch information...
1 parent 12c0ea9 commit cc90adfd2a171c5fc9f90f6a6506c5ac937efab3 @fxn fxn committed Aug 18, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/lib/action_view/template/resolver.rb
View
2 actionpack/lib/action_view/template/resolver.rb
@@ -157,7 +157,7 @@ def build_query(path, details)
end
def escape_entry(entry)
- entry.gsub(/(\*|\[|\]|\{|\}|\?)/, "\\\\\\1")
+ entry.gsub(/[*?{}\[\]]/, '\\\\\\&')
end
# Returns the file mtime from the filesystem.

0 comments on commit cc90adf

Please sign in to comment.