From 13775b3f579e575c0814ee17e5caacacc4972fd3 Mon Sep 17 00:00:00 2001 From: ssrangisetti <46807508+ssrangisetti@users.noreply.github.com> Date: Wed, 3 May 2023 22:52:49 +0530 Subject: [PATCH 1/2] Add support searching multiple words. --- src/utils/Search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/Search.js b/src/utils/Search.js index 50950183..6f9997c8 100644 --- a/src/utils/Search.js +++ b/src/utils/Search.js @@ -25,7 +25,7 @@ const getDomainFromUrl = (url) => { const filterHelper = (compareStr, searchStr) => { if (!compareStr) return false; const process = (input) => input && input.toString().toLowerCase().replace(/[^\w\s]/gi, ''); - return process(compareStr).includes(process(searchStr)); + return process(searchStr).split(/\s/).every(word => process(compareStr).includes(word)); }; /** From 3f3ffac63b3c54b60006612ab317f5ff84fe47a1 Mon Sep 17 00:00:00 2001 From: ssrangisetti Date: Wed, 3 May 2023 23:54:56 +0530 Subject: [PATCH 2/2] Fixing issues raised by SonarCloud --- src/utils/Search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/Search.js b/src/utils/Search.js index 6f9997c8..51da1411 100644 --- a/src/utils/Search.js +++ b/src/utils/Search.js @@ -11,7 +11,7 @@ import ErrorHandler from '@/utils/ErrorHandler'; const getDomainFromUrl = (url) => { if (!url) return ''; const urlPattern = /^(?:https?:\/\/)?(?:w{3}\.)?([a-z\d.-]+)\.(?:[a-z.]{2,10})(?:[/\w.-]*)*/; - const domainPattern = url.match(urlPattern); + const domainPattern = urlPattern.exec(url); return domainPattern ? domainPattern[1] : ''; }; @@ -24,7 +24,7 @@ const getDomainFromUrl = (url) => { */ const filterHelper = (compareStr, searchStr) => { if (!compareStr) return false; - const process = (input) => input && input.toString().toLowerCase().replace(/[^\w\s]/gi, ''); + const process = (input) => input?.toString().toLowerCase().replace(/[^\w\s]/gi, ''); return process(searchStr).split(/\s/).every(word => process(compareStr).includes(word)); };