-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ProjectCreateForm): added the ability to enter vowels in the pro…
…ject key
- Loading branch information
Showing
2 changed files
with
13 additions
and
10 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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
export const keyPredictor = (str: string) => | ||
str | ||
.trim() | ||
// eslint-disable-next-line no-control-regex | ||
.replace(/[^\x00-\x7F]/g, '') | ||
// eslint-disable-next-line no-useless-escape | ||
.replace(/[aeiou `~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]|/gi, '') | ||
.toUpperCase() | ||
.slice(0, 10); | ||
export const keyPredictor = (str: string, { allowVowels } = { allowVowels: false }) => { | ||
// eslint-disable-next-line no-control-regex | ||
let key = str.trim().replace(/[^\x00-\x7F]/g, ''); | ||
|
||
key = allowVowels | ||
? // eslint-disable-next-line no-useless-escape | ||
key.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]|/gi, '') | ||
: // eslint-disable-next-line no-useless-escape | ||
key.replace(/[aeiouy `~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]|/gi, ''); | ||
|
||
return key.toUpperCase().slice(0, 10); | ||
}; |