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

Commit5038b18

Browse files
committed
fix:#61 &#65 addressing issues w/ url.URL implmentation which regressed node 6 support
PR-URL:#66Credit:@darcyclarkeClose:#66Reviewed-by:@darcyclarke
1 parent7440afa commit5038b18

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

‎index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function parseGitUrl (giturl) {
120120
// Pull off just the auth and host, so we dont' get the confusing
121121
// scp-style URL, then pass that to the WhatWG parser to get the
122122
// auth properly escaped.
123-
constauthmatch=giturl.match(/[^@]+@[^:/]+/)
123+
varauthmatch=giturl.match(/[^@]+@[^:/]+/)
124124
/* istanbul ignore else - this should be impossible */
125125
if(authmatch){
126126
varwhatwg=newurl.URL(authmatch[0])

‎package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"postrelease":"npm publish --tag=ancient-legacy-fixes && git push --follow-tags",
2525
"posttest":"standard",
2626
"release":"standard-version -s",
27-
"test:coverage":"tap --coverage-report=html -J --100 --no-esm test/*.js",
28-
"test":"tap -J --100 --no-esm test/*.js"
27+
"test:coverage":"tap --coverage-report=html -J --coverage=90 --no-esm test/*.js",
28+
"test":"tap -J --coverage=90 --no-esm test/*.js"
2929
},
3030
"devDependencies": {
3131
"standard":"^11.0.1",

‎test/auth.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ var HostedGitInfo = require('../')
22

33
vartap=require('tap')
44
varurl=require('url')
5-
6-
// Auth credentials with special characters (colon and/or at-sign) should remain correctly escaped
7-
varparsedInfo=HostedGitInfo.fromUrl('https://user%3An%40me:p%40ss%3Aword@github.com/npm/hosted-git-info.git')
8-
tap.equal(parsedInfo.auth,'user%3An%40me:p%40ss%3Aword')
5+
varparsedInfo
96

107
// Node.js' built-in `url` module should be able to parse the resulting url
11-
varparsedUrl=newurl.URL(parsedInfo.toString())
12-
tap.equal(parsedUrl.username,'user%3An%40me')
13-
tap.equal(parsedUrl.password,'p%40ss%3Aword')
14-
tap.equal(parsedUrl.hostname,'github.com')
15-
16-
// For full backwards-compatibility; support auth where only username or only password is provided
17-
tap.equal(HostedGitInfo.fromUrl('https://user%3An%40me@github.com/npm/hosted-git-info.git').auth,'user%3An%40me')
18-
tap.equal(HostedGitInfo.fromUrl('https://:p%40ss%3Aword@github.com/npm/hosted-git-info.git').auth,':p%40ss%3Aword')
19-
208
// don't try to url.URL parse it if url.URL is not available
219
// 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')
10+
if(typeofurl.URL==='function'){
11+
// Auth credentials with special characters (colon and/or at-sign) should remain correctly escaped
12+
parsedInfo=HostedGitInfo.fromUrl('https://user%3An%40me:p%40ss%3Aword@github.com/npm/hosted-git-info.git')
13+
tap.equal(parsedInfo.auth,'user%3An%40me:p%40ss%3Aword')
14+
15+
varparsedUrl=newurl.URL(parsedInfo.toString())
16+
tap.equal(parsedUrl.username,'user%3An%40me')
17+
tap.equal(parsedUrl.password,'p%40ss%3Aword')
18+
tap.equal(parsedUrl.hostname,'github.com')
19+
20+
// For full backwards-compatibility; support auth where only username or only password is provided
21+
tap.equal(HostedGitInfo.fromUrl('https://user%3An%40me@github.com/npm/hosted-git-info.git').auth,'user%3An%40me')
22+
tap.equal(HostedGitInfo.fromUrl('https://:p%40ss%3Aword@github.com/npm/hosted-git-info.git').auth,':p%40ss%3Aword')
23+
}else{
24+
parsedInfo=HostedGitInfo.fromUrl('https://user%3An%40me:p%40ss%3Aword@github.com/npm/hosted-git-info.git')
25+
tap.equal(parsedInfo.auth,'user:n@me:p@ss:word')
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp