Permalink
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 4b411c8 commit 0df00d907982035bd74464720e7f8190a70dbcee @fxn fxn committed Aug 18, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 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.

0 comments on commit 0df00d9

Please sign in to comment.