Skip to content

Commit

Permalink
fix(isUrl): add proper validation for emails (#1425)
Browse files Browse the repository at this point in the history
  • Loading branch information
heanzyzabala authored Aug 31, 2020
1 parent 2ec9426 commit 0177658
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function isURL(url, options) {
return false;
}
auth = split.shift();
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
if (auth.indexOf(':') === -1 || (auth.indexOf(':') >= 0 && auth.split(':').length > 2)) {
return false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ describe('Validators', () => {
'http://[::FFFF:129.144.52.38]:80/index.html',
'http://[2010:836B:4179::836B:4179]',
'http://example.com/example.json#/foo/bar',
'http://user:@www.foobar.com',
],
invalid: [
'http://localhost:3000/',
Expand Down Expand Up @@ -379,6 +380,7 @@ describe('Validators', () => {
'////foobar.com',
'http:////foobar.com',
'https://example.com/foo/<script>alert(\'XSS\')</script>/',
'myemail@mail.com',
],
});
});
Expand Down

0 comments on commit 0177658

Please sign in to comment.