Skip to content

Conversation

wrknbuycnsmndie
Copy link

Description

This pull request fixes the issue where isURL incorrectly accepted email-like strings such as test@email.com as valid URLs.

Changes:

  • Added a check to detect email-like strings only when no protocol is present.
  • Respected the disallow_auth option to avoid breaking URLs containing authentication info like user:pass@host.

Closes #1674.


✅ All tests passed after the fix.
✅ No breaking changes for authentication URLs.
✅ Code style consistent with the rest of the project.

const emailLikeRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

if (!options || options.disallow_auth !== false) {
if (emailLikeRegex.test(url)) {

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with '!@!.' and with many repetitions of '!.'.
@wrknbuycnsmndie wrknbuycnsmndie closed this by deleting the head repository Aug 11, 2025
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.

isURL return true for e-mail
1 participant