« get me outta code hell

Merge branch 'tf-parser' into staging - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-05-07 15:31:48 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-05-07 15:31:48 -0300
commitcfb940ba021b1974c27b07dd0008b3bf065dad1e (patch)
tree8516adc329921f7ce1952df3d08e367f20400f98 /src/util
parent5522bb97469e50f7762259d310d9db246ef8ce4a (diff)
parent405069fdd35849d4fede8183b14918e060d7b78c (diff)
Merge branch 'tf-parser' into staging
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sugar.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js
index 9970bad..c24c617 100644
--- a/src/util/sugar.js
+++ b/src/util/sugar.js
@@ -68,3 +68,11 @@ export function queue(array, max = 50) {
 export function delay(ms) {
     return new Promise(res => setTimeout(res, ms));
 }
+
+// Stolen from here: https://stackoverflow.com/a/3561711
+//
+// There's a proposal for a native JS function like this, 8ut it's not even
+// past stage 1 yet: https://github.com/tc39/proposal-regex-escaping
+export function escapeRegex(string) {
+    return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+}