Skip to content

Commit e445692

Browse files
Merge pull request #127 from mashehu/master
Adds exact Match option
2 parents cfafa66 + b987c32 commit e445692

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/util.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function getValuesForKey (key, item) {
3939
return results.filter(r => typeof r === 'string' || typeof r === 'number')
4040
}
4141

42-
export function searchStrings (strings, term, {caseSensitive, fuzzy, sortResults} = {}) {
42+
export function searchStrings (strings, term, {caseSensitive, fuzzy, sortResults, exactMatch} = {}) {
4343
strings = strings.map(e => e.toString())
4444

4545
try {
@@ -58,6 +58,9 @@ export function searchStrings (strings, term, {caseSensitive, fuzzy, sortResults
5858
if (!caseSensitive) {
5959
value = value.toLowerCase()
6060
}
61+
if (exactMatch) {
62+
term = new RegExp('^' + term + '$', 'i')
63+
}
6164
if (value && value.search(term) !== -1) {
6265
return true
6366
}

0 commit comments

Comments
 (0)