Skip to content

Commit

Permalink
fix(isUrl): allow url with column and no port (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPierro committed Oct 30, 2021
1 parent 6b213cf commit 60dffb9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isURL.js
Expand Up @@ -136,7 +136,7 @@ export default function isURL(url, options) {
}
}

if (port_str !== null) {
if (port_str !== null && port_str.length > 0) {
port = parseInt(port_str, 10);
if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
return false;
Expand Down
25 changes: 25 additions & 0 deletions test/validators.js
Expand Up @@ -535,6 +535,31 @@ describe('Validators', () => {
});
});

it('should validate URLs with column and no port', () => {
test({
validator: 'isURL',
valid: [
'http://example.com:',
'ftp://example.com:',
],
invalid: [
'https://example.com:abc',
],
});
});

it('should validate sftp protocol URL containing column and no port', () => {
test({
validator: 'isURL',
args: [{
protocols: ['sftp'],
}],
valid: [
'sftp://user:pass@terminal.aws.test.nl:/incoming/things.csv',
],
});
});

it('should validate protocol relative URLs', () => {
test({
validator: 'isURL',
Expand Down

0 comments on commit 60dffb9

Please sign in to comment.