-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(FieldFormatters): normalize ^ and $ in regex
Fixes #5075 (review)
- Loading branch information
1 parent
5403155
commit 9b664c9
Showing
5 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
specifyweb/frontend/js_src/lib/components/FieldFormatters/__tests__/spec.test.ts
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,23 @@ | ||
import { theories } from '../../../tests/utils'; | ||
import { exportsForTests } from '../spec'; | ||
|
||
const { trimRegexString, normalizeRegexString } = exportsForTests; | ||
|
||
theories(trimRegexString, [ | ||
[[''], ''], | ||
[['[a-z]{3,}.*'], '[a-z]{3,}.*'], | ||
[['/^[a-z]{3,}.*$/'], '[a-z]{3,}.*'], | ||
[['^\\d{3}$'], '\\d{3}'], | ||
[['/^(KUI|KUBI|NHM)$/'], 'KUI|KUBI|NHM'], | ||
]); | ||
|
||
theories(normalizeRegexString, [ | ||
[[''], '/^$/'], | ||
[['[a-z]{3,}.*'], '/^[a-z]{3,}.*$/'], | ||
[['/^[a-z]{3,}.*$/'], '/^[a-z]{3,}.*$/'], | ||
[['^\\d{3}$'], '/^\\d{3}$/'], | ||
[['\\d{3}'], '/^\\d{3}$/'], | ||
[['/\\d{3}/'], '/^\\d{3}$/'], | ||
[['KUI|KUBI|NHM'], '/^(KUI|KUBI|NHM)$/'], | ||
[['(KUI|KUBI)|NHM'], '/^((KUI|KUBI)|NHM)$/'], | ||
]); |
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
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