Skip to content

Commit

Permalink
fix: regex error
Browse files Browse the repository at this point in the history
  • Loading branch information
KUN1007 committed Jan 4, 2025
1 parent 2cc7be5 commit 561105f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kun-galgame-nuxt3",
"version": "2.19.27",
"version": "2.19.28",
"packageManager": "[email protected]",
"private": true,
"scripts": {
Expand Down
62 changes: 59 additions & 3 deletions utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,65 @@ export const isValidEmail = (email: string) => {
}

export const isValidName = (name: string) => {
const invisibleCharRegex =
/[\x09\x20\xA0\xAD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180E\u2000-\u200F\u202F\u205F\u2060-\u206F\u3000\u2800\u3164\uFEFF\uFFA0\uD800-\uDBFF\uDC00-\uDFFF\u1D159\u1D173-\u1D179\u1D17A\uE0020]+/g
if (invisibleCharRegex.test(name)) {
const invisibleChars = [
'\u0009',
'\u0020',
'\u00A0',
'\u00AD',
'\u034F',
'\u061C',
'\u115F',
'\u1160',
'\u17B4',
'\u17B5',
'\u180E',
'\u2000',
'\u2001',
'\u2002',
'\u2003',
'\u2004',
'\u2005',
'\u2006',
'\u2007',
'\u2008',
'\u2009',
'\u200A',
'\u200B',
'\u200C',
'\u200D',
'\u200E',
'\u200F',
'\u202F',
'\u205F',
'\u2060',
'\u2061',
'\u2062',
'\u2063',
'\u2064',
'\u2065',
'\u206A',
'\u206B',
'\u206C',
'\u206D',
'\u206E',
'\u206F',
'\u3000',
'\u2800',
'\u3164',
'\uFEFF',
'\uFFA0',
'\u1D159',
'\u1D173',
'\u1D174',
'\u1D175',
'\u1D176',
'\u1D177',
'\u1D178',
'\u1D179',
'\u1D17A',
'\uE0020'
]
if (invisibleChars.some((char) => name.includes(char))) {
return false
}
const regex = /^[\p{L}\p{N}!~_@#$%^&*()+=-]{1,17}$/u
Expand Down

0 comments on commit 561105f

Please sign in to comment.