mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 13:56:29 +02:00
Secure with jwt
This commit is contained in:
18
src/utils/standardization.ts
Normal file
18
src/utils/standardization.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export function canonicalEmail(email: string): string {
|
||||
email = email.replace(/^\s+|\s+$/g, "")
|
||||
if (/@gmail.com$/.test(email)) {
|
||||
let domain = email.replace(/^.*@/, "")
|
||||
domain = domain.replace(/^googlemail%.com$/, "gmail.com")
|
||||
email = email
|
||||
.replace(/\./g, "")
|
||||
.replace(/^[^@]+/, (match) => match.toLowerCase())
|
||||
.replace(/@.*$/, `@${domain}`)
|
||||
}
|
||||
return email.toLowerCase()
|
||||
}
|
||||
|
||||
export function validEmail(email: string): boolean {
|
||||
return /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/.test(
|
||||
email
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user