Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b16ba3

Browse filesBrowse files
mscdexsilverwind
authored andcommitted
url: fix off-by-one error with parse()
Fixes: #5393 PR-URL: #5394 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Evan Lucas <evanlucas@me.com>
1 parent 3a331b6 commit 8b16ba3
Copy full SHA for 8b16ba3

File tree

Expand file treeCollapse file tree

2 files changed

+16
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-1
lines changed
Open diff view settings
Collapse file

‎lib/url.js‎

Copy file name to clipboardExpand all lines: lib/url.js
+1-1Lines changed: 1 addition & 1 deletion
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
}
Collapse file

‎test/parallel/test-url.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-url.js
+15Lines changed: 15 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.