Skip to content

Commit 0177658

Browse files
authored
fix(isUrl): add proper validation for emails (#1425)
1 parent 2ec9426 commit 0177658

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/lib/isURL.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default function isURL(url, options) {
100100
return false;
101101
}
102102
auth = split.shift();
103-
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
103+
if (auth.indexOf(':') === -1 || (auth.indexOf(':') >= 0 && auth.split(':').length > 2)) {
104104
return false;
105105
}
106106
}

test/validators.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ describe('Validators', () => {
339339
'http://[::FFFF:129.144.52.38]:80/index.html',
340340
'http://[2010:836B:4179::836B:4179]',
341341
'http://example.com/example.json#/foo/bar',
342+
'http://user:@www.foobar.com',
342343
],
343344
invalid: [
344345
'http://localhost:3000/',
@@ -379,6 +380,7 @@ describe('Validators', () => {
379380
'////foobar.com',
380381
'http:////foobar.com',
381382
'https://example.com/foo/<script>alert(\'XSS\')</script>/',
383+
382384
],
383385
});
384386
});

0 commit comments

Comments
 (0)