diff options
| author | mrmr1993 | 2015-09-11 13:26:31 +0100 | 
|---|---|---|
| committer | mrmr1993 | 2015-09-11 13:26:31 +0100 | 
| commit | ce2809a76e08780955198c11fc63eb990cd575cf (patch) | |
| tree | 49a07e27b9f87c07bc6986507e8187158f101b1e /background_scripts/completion.coffee | |
| parent | 4e5b82e3783bebe640ce98df4bd432da7640c69d (diff) | |
| download | vimium-ce2809a76e08780955198c11fc63eb990cd575cf.tar.bz2 | |
Move escaping regex special chars to its own utility function
Diffstat (limited to 'background_scripts/completion.coffee')
| -rw-r--r-- | background_scripts/completion.coffee | 4 | 
1 files changed, 1 insertions, 3 deletions
| diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index fb5a6120..2427bad8 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -762,8 +762,6 @@ RegexpCache =    init: ->      @initialized = true      @clear() -    # Taken from http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex -    @escapeRegExp ||= /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g    clear: -> @cache = {} @@ -777,7 +775,7 @@ RegexpCache =    # TODO: `prefix` and `suffix` might be useful in richer word-relevancy scoring.    get: (string, prefix="", suffix="") ->      @init() unless @initialized -    regexpString = string.replace(@escapeRegExp, "\\$&") +    regexpString = Utils.escapeRegexSpecialCharacters string      # Avoid cost of constructing new strings if prefix/suffix are empty (which is expected to be a common case).      regexpString = prefix + regexpString if prefix      regexpString = regexpString + suffix if suffix | 
