aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.coffee')
-rw-r--r--lib/utils.coffee6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 350b11a5..b69b926b 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, "&lt;").replace(/>/g, "&gt;")
# Generates a unique ID