Skip to content

Commit 5a9ce4f

Browse files
committed
Correctly handle exclude option regex with global flag
Fixes #47
1 parent 5f2c970 commit 5a9ce4f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ const mapObj = require('map-obj');
33
const camelCase = require('camelcase');
44
const QuickLru = require('quick-lru');
55

6-
const has = (array, key) => array.some(x => typeof x === 'string' ? x === key : x.test(key));
6+
const has = (array, key) => array.some(x => {
7+
if (typeof x === 'string') {
8+
return x === key;
9+
}
10+
11+
x.lastIndex = 0;
12+
return x.test(key);
13+
});
14+
715
const cache = new QuickLru({maxSize: 100000});
816

917
// Reproduces behavior from `map-obj`

0 commit comments

Comments
 (0)