forked from npm/hosted-git-info
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not use url.URL to support early node 6 and scp-style URLs
- Loading branch information
1 parent
e1b83df
commit 2dedc7b
Showing
3 changed files
with
5 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
var HostedGitInfo = require('../') | ||
|
||
var tap = require('tap') | ||
var url = require('url') | ||
|
||
// Auth credentials with special characters (colon and/or at-sign) should remain correctly escaped | ||
var parsedInfo = HostedGitInfo.fromUrl('https://user%3An%40me:p%40ss%[email protected]/npm/hosted-git-info.git') | ||
tap.equal(parsedInfo.auth, 'user%3An%40me:p%40ss%3Aword') | ||
|
||
// Node.js' built-in `url` module should be able to parse the resulting url | ||
var parsedUrl = new url.URL(parsedInfo.toString()) | ||
tap.equal(parsedUrl.username, 'user%3An%40me') | ||
tap.equal(parsedUrl.password, 'p%40ss%3Aword') | ||
tap.equal(parsedUrl.hostname, 'github.com') | ||
|
||
// For full backwards-compatibility; support auth where only username or only password is provided | ||
tap.equal(HostedGitInfo.fromUrl('https://user%3An%[email protected]/npm/hosted-git-info.git').auth, 'user%3An%40me') | ||
tap.equal(HostedGitInfo.fromUrl('https://:p%40ss%[email protected]/npm/hosted-git-info.git').auth, ':p%40ss%3Aword') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,11 @@ test('basic', function (t) { | |
t.is(HostedGit.fromUrl(), undefined, 'no value is not hosted') | ||
t.is(HostedGit.fromUrl('git+file:///foo/bar'), undefined, 'url that has no host') | ||
t.is(HostedGit.fromUrl('github.com/abc/def/'), undefined, 'forgot the protocol') | ||
t.is(HostedGit.fromUrl('//github.com/abc/def/'), undefined, 'forgot the protocol') | ||
t.is(HostedGit.fromUrl('completely-invalid'), undefined, 'not a url is not hosted') | ||
|
||
t.is(HostedGit.fromUrl('git+ssh://[email protected]:RND/electron-tools/some-tool#2.0.1'), undefined, 'properly ignores non-hosted scp style urls') | ||
|
||
t.is(HostedGit.fromUrl('http://github.com/foo/bar').toString(), 'git+ssh://[email protected]/foo/bar.git', 'github http protocol use git+ssh urls') | ||
t.end() | ||
}) |