Skip to content

Commit

Permalink
Merge pull request #417 from saplingjs/fix/use-wildcard-matcher
Browse files Browse the repository at this point in the history
Use `matchWildcard` for Memory driver
  • Loading branch information
groenroos authored Feb 21, 2022
2 parents 1cb6ee1 + 6ad95ce commit e166328
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 e166328

Please sign in to comment.