Skip to content

Commit

Permalink
Use matchWildcard for Memory
Browse files Browse the repository at this point in the history
  • Loading branch information
groenroos committed Feb 21, 2022
1 parent 1cb6ee1 commit 6ad95ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/db/Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default class Memory extends Interface {

/* If we have wildcards, build a regex */
if (String(value).includes('*')) {
return String(record[field]).match(new RegExp(`^${value.split('*').join('(.*)')}$`, 'gmi')) !== null;
return new Utils().matchWildcard(record[field], value);
}

/* Otherwise do a direct match */
Expand Down
2 changes: 1 addition & 1 deletion lib/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class Utils {
*/
matchWildcard(string, rule) {
const escapeRegex = string => string.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
return new RegExp(`^${String(rule).split('*').map(element => escapeRegex(element)).join('.*')}$`).test(String(string));
return new RegExp(`^${String(rule).split('*').map(element => escapeRegex(element)).join('.*')}$`, 'i').test(String(string));
}


Expand Down

0 comments on commit 6ad95ce

Please sign in to comment.