Skip to content

Commit b6e847a

Browse files
committed
url: fix off-by-one error with parse()
Fixes: nodejs#5393
1 parent 65c0feb commit b6e847a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function validateHostname(self, rest, hostname) {
413413
}
414414
// Invalid host character
415415
self.hostname = hostname.slice(0, i);
416-
if (i < hostname.length - 1)
416+
if (i < hostname.length)
417417
return '/' + hostname.slice(i) + rest;
418418
break;
419419
}

test/parallel/test-url.js

+15
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,21 @@ var parseTests = {
851851
pathname: '/:npm/npm',
852852
path: '/:npm/npm',
853853
href: 'git+ssh://git@github.com/:npm/npm'
854+
},
855+
856+
'https://*': {
857+
protocol: 'https:',
858+
slashes: true,
859+
auth: null,
860+
host: '',
861+
port: null,
862+
hostname: '',
863+
hash: null,
864+
search: null,
865+
query: null,
866+
pathname: '/*',
867+
path: '/*',
868+
href: 'https:///*'
854869
}
855870

856871
};

0 commit comments

Comments
 (0)