File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,23 @@ const correctProtocol = (arg, protocols) => {
2121 return arg
2222 }
2323
24+ if ( arg . substr ( firstColon , 3 ) === '://' ) {
25+ // If arg is given as <foo>://<bar>, then this is already a valid URL.
26+ return arg
27+ }
28+
2429 const firstAt = arg . indexOf ( '@' )
2530 if ( firstAt > - 1 ) {
2631 if ( firstAt > firstColon ) {
32+ // URL has the form of <foo>:<bar>@<baz>. Assume this is a git+ssh URL.
2733 return `git+ssh://${ arg } `
2834 } else {
35+ // URL has the form 'git@github.com:npm/hosted-git-info.git'.
2936 return arg
3037 }
3138 }
3239
33- const doubleSlash = arg . indexOf ( '//' )
34- if ( doubleSlash === firstColon + 1 ) {
35- return arg
36- }
37-
40+ // Correct <foo>:<bar> to <foo>://<bar>
3841 return `${ arg . slice ( 0 , firstColon + 1 ) } //${ arg . slice ( firstColon + 1 ) } `
3942}
4043
Original file line number Diff line number Diff line change @@ -15,3 +15,10 @@ t.test('can parse file urls', async t => {
1515 t . ok ( parseUrl ( u ) )
1616 t . ok ( HostedGit . parseUrl ( u ) )
1717} )
18+
19+ t . test ( 'can parse custom urls' , async t => {
20+ const u = 'foobar://user:host@path'
21+ t . ok ( parseUrl ( u , { } ) )
22+ t . equal ( parseUrl ( u , { } ) . protocol , 'foobar:' )
23+ t . ok ( HostedGit . parseUrl ( u ) )
24+ } )
You can’t perform that action at this time.
0 commit comments