diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils.coffee | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee index 90469fad..e0b9ba36 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -19,6 +19,12 @@ Utils = func = obj[components.pop()] func.apply(obj, argArray) + # Escape all special characters, so RegExp will parse the string 'as is'. + # Taken from http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex + escapeRegexSpecialCharacters: do -> + escapeRegex = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g + (str) -> str.replace escapeRegex, "\\$&" + escapeHtml: (string) -> string.replace(/</g, "<").replace(/>/g, ">") # Generates a unique ID |
