Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows email address domains to be IP addresses #1435

Closed

Conversation

Tyler-Murphy
Copy link

Sorry I didn't make an issue first. Figured it's a small change, so I'd just offer a solution whether it's acceptable or not.

References:

This doesn't make sure the IP address is valid. It only makes sure that it's not obviously invalid.

References:
- https://learn.microsoft.com/en-us/archive/blogs/testing123/email-address-test-cases
- validatorjs/validator.js#800

This doesn't make sure the IP address is valid. It only makes sure that it's not obviously invalid.
@netlify
Copy link

netlify bot commented Sep 27, 2022

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 93be5e5
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63337cf14aa407000a64eca7
😎 Deploy Preview https://deploy-preview-1435--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@kibertoad
Copy link

can you benchmark perf impact of this change on plain emails?

@kibertoad
Copy link

I think validator.js approach of making this optional generally makes more sense, especially if this makes the hot path regex slower

@Tyler-Murphy
Copy link
Author

Sure, added to benchmarks/string.ts like this:

const emailSchema = z.string().email()

...

  .add("email", () => {
    emailSchema.parse(`someone@example.com`)
  })

Without IP support: 7,224,694 ops/sec ±0.59% (96 runs sampled)
With IP support: 7,175,461 ops/sec ±0.62% (92 runs sampled)

I also tried with 1000 random email addresses from https://www.randomlists.com/email-addresses?qty=1000 where each one was checked in a for .. of loop.

Without IP support: 7,459 ops/sec ±0.39% (97 runs sampled)
With IP support: 7,584 ops/sec ±0.56% (97 runs sampled)

And finally, I replaced two of the 1000 random email addresses with email addresses that use IP addresses, still using the regex with IP support: 7,663 ops/sec ±0.41% (97 runs sampled)

The speed is so similar that I don't think it's worth making it optional.

@stale
Copy link

stale bot commented Nov 29, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No activity in last 60 days label Nov 29, 2022
@Tyler-Murphy
Copy link
Author

Leave open

@stale stale bot removed the stale No activity in last 60 days label Nov 29, 2022
@stale
Copy link

stale bot commented May 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No activity in last 60 days label May 10, 2023
@Tyler-Murphy
Copy link
Author

Not stale

@stale stale bot removed the stale No activity in last 60 days label May 10, 2023
@stale
Copy link

stale bot commented Aug 8, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No activity in last 60 days label Aug 8, 2023
@Tyler-Murphy
Copy link
Author

not stale

@stale stale bot removed the stale No activity in last 60 days label Aug 9, 2023
@colinhacks
Copy link
Owner

Thanks for this (now very old) PR! The final word on email regexes landed here: #2157 Further discussion can happen in new issues/PRs. 👍

@colinhacks colinhacks closed this Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants