about summary refs log tree commit diff
path: root/app/javascript/mastodon/selectors
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/selectors')
-rw-r--r--app/javascript/mastodon/selectors/index.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/javascript/mastodon/selectors/index.js b/app/javascript/mastodon/selectors/index.js
index d0212c379..106198f74 100644
--- a/app/javascript/mastodon/selectors/index.js
+++ b/app/javascript/mastodon/selectors/index.js
@@ -47,7 +47,18 @@ export const regexFromFilters = filters => {
 
   return new RegExp(filters.map(filter => {
     let expr = escapeRegExp(filter.get('phrase'));
-    return filter.get('whole_word') ? `\\b${expr}\\b` : expr;
+
+    if (filter.get('whole_word')) {
+      if (/^[\w]/.test(expr)) {
+        expr = `\\b${expr}`;
+      }
+
+      if (/[\w]$/.test(expr)) {
+        expr = `${expr}\\b`;
+      }
+    }
+
+    return expr;
   }).join('|'), 'i');
 };