Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit2d0bb66

Browse files
committed
fix: Do not attempt to use url.URL when unavailable
Fix#61This should not be ported to the latest branch, as Node.js v6 supportwas dropped there anyway.PR-URL:#62Credit:@isaacsClose:#62Reviewed-by:@isaacs
1 parentf2cdfcf commit2d0bb66

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎index.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ function parseGitUrl (giturl) {
108108
varmatched=giturl.match(/^([^@]+)@([^:/]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
109109
if(!matched){
110110
varlegacy=url.parse(giturl)
111-
if(legacy.auth){
111+
// If we don't have url.URL, then sorry, this is just not fixable.
112+
// This affects Node <= 6.12.
113+
if(legacy.auth&&typeofurl.URL==='function'){
112114
// git urls can be in the form of scp-style/ssh-connect strings, like
113115
// git+ssh://user@host.com:some/path, which the legacy url parser
114116
// supports, but WhatWG url.URL class does not. However, the legacy

‎test/auth.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ tap.equal(parsedUrl.hostname, 'github.com')
1616
// For full backwards-compatibility; support auth where only username or only password is provided
1717
tap.equal(HostedGitInfo.fromUrl('https://user%3An%40me@github.com/npm/hosted-git-info.git').auth,'user%3An%40me')
1818
tap.equal(HostedGitInfo.fromUrl('https://:p%40ss%3Aword@github.com/npm/hosted-git-info.git').auth,':p%40ss%3Aword')
19+
20+
// don't try to url.URL parse it if url.URL is not available
21+
// ie, node <6.13. This is broken, but at least it doesn't throw.
22+
url.URL=null
23+
varparsedInfoNoURL=HostedGitInfo.fromUrl('https://user%3An%40me:p%40ss%3Aword@github.com/npm/xyz.git')
24+
tap.equal(parsedInfoNoURL.auth,'user:n@me:p@ss:word')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp