about summary refs log tree commit diff
path: root/app/javascript/mastodon/selectors
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-07-09 02:22:09 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-07-09 02:22:09 +0200
commit1ca4e51eb38de6de81cedf3ddcdaa626f1d1c569 (patch)
tree3cf44ef95b178d233fd34d2ec2aae2a7021c159d /app/javascript/mastodon/selectors
parent451e585b9720c61ef9a155a16484b25ded79d512 (diff)
Add option to not consider word boundaries when processing keyword filtering (#7975)
* Add option to not consider word boundaries when filtering phrases

* Add a few tests for keyword/phrase filtering
Diffstat (limited to 'app/javascript/mastodon/selectors')
-rw-r--r--app/javascript/mastodon/selectors/index.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/javascript/mastodon/selectors/index.js b/app/javascript/mastodon/selectors/index.js
index 7aa7569a0..d0212c379 100644
--- a/app/javascript/mastodon/selectors/index.js
+++ b/app/javascript/mastodon/selectors/index.js
@@ -45,7 +45,10 @@ export const regexFromFilters = filters => {
     return null;
   }
 
-  return new RegExp(filters.map(filter => escapeRegExp(filter.get('phrase'))).map(expr => `\\b${expr}\\b`).join('|'), 'i');
+  return new RegExp(filters.map(filter => {
+    let expr = escapeRegExp(filter.get('phrase'));
+    return filter.get('whole_word') ? `\\b${expr}\\b` : expr;
+  }).join('|'), 'i');
 };
 
 export const makeGetStatus = () => {