From d01c8396163e939355c41700b8a4a9c47e0edda5 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Mon, 6 Feb 2023 13:04:35 +0100 Subject: [PATCH] fix: fix regex detection --- public/script/app.js | 2 +- src/anonymize-utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/script/app.js b/public/script/app.js index 52454b7..4e4eb09 100644 --- a/public/script/app.js +++ b/public/script/app.js @@ -1233,7 +1233,7 @@ angular function anonymize() { $scope.anonymize.terms.$setValidity("regex", true); // check if string has regex characters - if ($scope.terms && $scope.terms.match(/[-[\]{}()*+?.,\\^$|#\s]/g)) { + if ($scope.terms && $scope.terms.match(/[-[\]{}()*+?.,\\^$|#]/g)) { $scope.anonymize.terms.$setValidity("regex", false); } const urlRegex = diff --git a/src/anonymize-utils.ts b/src/anonymize-utils.ts index ddd627e..06406e0 100644 --- a/src/anonymize-utils.ts +++ b/src/anonymize-utils.ts @@ -141,7 +141,7 @@ export function anonymizeContent( new RegExp(term, "gi"); } catch { // escape regex characters - term = term.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + term = term.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&"); } // remove whole url if it contains the term content = content.replace(urlRegex, (match) => { @@ -169,7 +169,7 @@ export function anonymizePath(path: string, terms: string[]) { new RegExp(term, "gi"); } catch { // escape regex characters - term = term.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + term = term.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&"); } path = path.replace( new RegExp(term, "gi"),