-
Notifications
You must be signed in to change notification settings - Fork 15
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
Matches email addresses (within a larger string) with default options #5
Comments
Actually there is a test similar to this that seems counterintuitive given my limited understanding of the interplay between the options and the aforementioned comment on that issue with url-regex:
Is that test case supposed to be finding:
I would suggest more detailed documentation to help eliminate ambiguity if this is in fact not a bug. Although if it is not a bug, that brings up the question of whether this module can currently be configured to behave as desired in this issue report, or if that would be an enhancement. Personally I see the value in use cases that separate email address from other types of URLs, and would want an option to explicitly include/exclude them. Moreover (and perhaps most importantly), in a string like "Please use this Authority URL with username: [email protected] to access the site", I personally would not even consider that to be a valid Authority URL in any context whatsoever. A string with that syntax is an email address. In the modern world in the limited scenarios where Authority URLs are still used, they should always be be prefixed with a scheme and if they are not, they should not be considered Authority URLs regardless of what the spec (RFCs) say (in a context where email addresses may be present). Edit: Also I don't see why "bar.com" is the matched substring for "[email protected]" either. If "[email protected]" is considered a URL, shouldn't the entire thing be matched and not just the part after the "@"? Another way of saying this is that if you think you have found a valid URL within a given string, but that URL is preceded by an "@" sign, then you have either not found a valid URL or you have found only a portion of a URL. There are very few non-whitespace characters that I would say are valid to be directly preceding a URL. Perhaps bracket/quote characters might be acceptable e.g. ( [ { ` ' " < I guess it (characters that can precede a URL) depends on whether the string being parsed is generally human-readable stuff or if it's code or machine-readable. |
I think you're looking for |
You could use |
If you take this string: "Please send an email to [email protected], providing ONLY your first name", this module will return "test.com" as a match.
Is this intended behavior and I am just misunderstanding how it's supposed to work?
I see that the "auth" option (if set to true) may result in undesired matches to email addresses, but it defaults to false.
I don't see a test case in the tests for this scenario.(see comment below)What's interesting is that you commented on this exact problem in a relevant url-regex issue:
...
Here are the relevant options that might impact this test, although they are all just their default values so wouldn't need to be explicitly set in a test:
exact: false
strict: false
auth: false
The text was updated successfully, but these errors were encountered: