about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util/counter.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/flavours/glitch/util/counter.js')
-rw-r--r--app/javascript/flavours/glitch/util/counter.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/util/counter.js b/app/javascript/flavours/glitch/util/counter.js
new file mode 100644
index 000000000..7aa9e87b1
--- /dev/null
+++ b/app/javascript/flavours/glitch/util/counter.js
@@ -0,0 +1,9 @@
+import { urlRegex } from './url_regex';
+
+const urlPlaceholder = '$2xxxxxxxxxxxxxxxxxxxxxxx';
+
+export function countableText(inputText) {
+  return inputText
+    .replace(urlRegex, urlPlaceholder)
+    .replace(/(^|[^\/\w])@(([a-z0-9_]+)@[a-z0-9\.\-]+[a-z0-9]+)/ig, '$1@$3');
+};