From faa4db7975c7ec2ca1bbed19047fe6900d3d5599 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 9 Jul 2018 22:40:27 +0200 Subject: [PATCH] [Glitch] Add option to not consider word boundaries when processing keyword filtering Port 1ca4e51eb38de6de81cedf3ddcdaa626f1d1c569 to glitch-soc --- app/javascript/flavours/glitch/selectors/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/selectors/index.js b/app/javascript/flavours/glitch/selectors/index.js index 7aa7569a054..d0212c379d6 100644 --- a/app/javascript/flavours/glitch/selectors/index.js +++ b/app/javascript/flavours/glitch/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 = () => {