Skip to content

Commit

Permalink
remove email-validator dep
Browse files Browse the repository at this point in the history
  • Loading branch information
imlautaro committed Dec 29, 2022
1 parent 930aae7 commit 08708e9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"dependencies": {
"@nuxtjs/supabase": "^0.3.0",
"email-validator": "^2.0.4",
"oxecore": "^0.0.1",
"uuid": "^9.0.0"
}
Expand Down
7 changes: 0 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/composables/useSupauth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Provider } from '@supabase/gotrue-js'
import { validate } from 'email-validator'

export default () => {
const supaAuth = useSupabaseAuthClient().auth
Expand Down
25 changes: 25 additions & 0 deletions src/utils/email-validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const tester =
/^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/

export const validate = (email: string) => {
if (!email || email.length > 254) {
return false
}

let valid = tester.test(email)
if (!valid) {
return false
}

let parts = email.split('@')
if (parts[0].length > 64) {
return false
}

let domainParts = parts[1].split('.')
if (domainParts.some(part => part.length > 63)) {
return false
}

return true
}

0 comments on commit 08708e9

Please sign in to comment.