-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Describe the bug
Hi,
What is the correct behaviour for isURL
function when I give e-mail address? I would expect that return false.
Examples
An example from the Node REPL:
Welcome to Node.js v14.16.0.
Type ".help" for more information.
> var validator = require('validator');
undefined
> validator.isURL('user@example.com');
true
>
Additional context
Validator.js version: 13.6.0
Node.js version: 14.16.0
OS platform: macOS
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
brybrophy commentedon May 24, 2021
I was going to submit a PR to fix this, but then I saw these tests...
validator.js/test/validators.js
Lines 672 to 688 in 907bb07
It seems that you can set the
disallow_auth
option totrue
and it will fail validation on an email.mjancarik commentedon Jun 11, 2021
Hi,
Thank you. I will try it. I would expect default behaviour with
disallow_auth
totrue
.raghavbk commentedon Oct 3, 2021
@ezkemboi can i work on this issue
ezkemboi commentedon Oct 3, 2021
@raghavbk if you have a PR, please do it and we will review it. Thanks.
Jassi10000-zz commentedon Oct 25, 2021
@mjancarik
Buddy can you tell one thing
user@example.com : This will treated as an email due to the presence of " @ " in it , so I think its bound to return true to this
ffxsam commentedon Mar 12, 2023
In no way is an email address a URL, as someone claimed in an issue.
mailto:xyz@xyz.net
is a URL/URI, butxyz@xyz.net
is not. This should be considered a bug.Yuniac commentedon May 9, 2024
Well, till someone figure out which way is the correct way, doing this works for everyone else:
WikiRik commentedon Mar 28, 2025
This is desired behaviour atm, see also #1753 (comment)
The option
disallow_auth
is provided for this usecaseffxsam commentedon Apr 9, 2025
The maintainers are obviously free to do what they want, but anyone arguing that
user@example.com
is a URL is flat-out wrong. It's not something subjective that's up for debate. I can cite evidence:https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.3
URI/URL examples: https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.2
The RFC spec says "Each URI begins with a scheme name" and provides another clear example:
Sorry to be pedantic, but if we're going to quote someone who claims that
user@example.com
is a URL "per spec," I think it needs to be called out.I'm open to being challenged if someone can provide authoritative sources.
WikiRik commentedon Apr 9, 2025
Thanks for the extensive response, I've reopened the issue so we can take another look at it
ffxsam commentedon Apr 9, 2025
@WikiRik I appreciate being open to it! If there's no room for pedantry in engineering, then it ain't engineering. 😝