mirror of
https://github.com/status-im/consul.git
synced 2025-01-14 15:54:40 +00:00
9d21736e9f
* Add copyright headers to UI files * Ensure copywrite file ignores external libs
21 lines
474 B
JavaScript
21 lines
474 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import PredicateSearch from './predicate';
|
|
|
|
export default class RegExpSearch extends PredicateSearch {
|
|
predicate(s) {
|
|
let regex;
|
|
try {
|
|
regex = new RegExp(s, 'i');
|
|
} catch (e) {
|
|
// Return a predicate that excludes everything; most likely due to an
|
|
// eager search of an incomplete regex
|
|
return () => false;
|
|
}
|
|
return (item) => regex.test(item);
|
|
}
|
|
}
|