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

[fix] [email protected] does not match #8

Open
3 tasks done
analog-nico opened this issue Jan 22, 2024 · 1 comment
Open
3 tasks done

[fix] [email protected] does not match #8

analog-nico opened this issue Jan 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@analog-nico
Copy link
Contributor

analog-nico commented Jan 22, 2024

Describe the bug

I ran it on RunKit and on my local system:

Node.js version: 18.11 and 20.9

OS version: RunKit’s OS and Mac OS X

Description: emailRegex.test('[email protected]') returns false. Note that the local part has only 1 character. If I add a second character it works fine.

Actual behavior

emailRegex.test('[email protected]') returns false

Expected behavior

emailRegex.test('[email protected]') returns true

Code to reproduce

require("re2/package.json"); // re2 is a peer dependency. 
var emailRegexSafe = require("email-regex-safe")

let emailRegex = emailRegexSafe({ exact: true, gmail: false })

emailRegex.test('[email protected]')

Run this code on RunKit

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@analog-nico analog-nico added the bug Something isn't working label Jan 22, 2024
@analog-nico
Copy link
Contributor Author

I looked into the generated regex:

(?:[^\W_](?:[a-z\d!#\$%&'\.\*\+\-\/=\?\^_{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)@...)`

The (?:[^\W_] part seems to be the culprit. Unfortunately, I don’t understand why it is not an issue if the local part of the email address has more than 1 character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant