-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(planter filter): include partial matches in results (#165)
* feat(planter filter): include partial matches in results * refactor(planter filter): move stringToSearchRegExp function to utilities * doc: fix typo in comment Co-authored-by: Nick Charlton <[email protected]>
- Loading branch information
1 parent
3bc15bc
commit 90d493e
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @function | ||
* @name stringToSearchRegExp | ||
* @description Converts a string to a case-insensitive regular expression | ||
* that can be used to search for string patterns. | ||
* | ||
* @param {string} value The string to convert. | ||
* @returns {string} A regular expression string | ||
*/ | ||
export const stringToSearchRegExp = (value) => `/.*${value}.*/i`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { stringToSearchRegExp } from './'; | ||
|
||
describe('converts string to regexp', () => { | ||
it('it should convert string to regexp', () => { | ||
const result = stringToSearchRegExp('test'); | ||
expect(result).toEqual(`/.*test.*/i`); | ||
}); | ||
}); |