File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,26 @@ const correctProtocol = (arg, protocols) => {
2121 return arg
2222 }
2323
24- const doubleSlash = arg . indexOf ( '//' )
25- if ( doubleSlash === firstColon + 1 ) {
24+ if ( arg . substr ( firstColon , 3 ) === '://' ) {
25+ // If arg is given as <foo>://<bar>, then this is already a valid URL and
26+ // we assume the user provided a protocol.
2627 return arg
2728 }
2829
2930 const firstAt = arg . indexOf ( '@' )
3031 if ( firstAt > - 1 ) {
3132 if ( firstAt > firstColon ) {
33+ // The URL has the form of <foo>:<bar>@<baz>. We assume this is a git+ssh
34+ // URL.
3235 return `git+ssh://${ arg } `
3336 } else {
37+ // The URL has the form of <foo>@<bar> which is likely a shortcut URL
38+ // such as @npm /cli
3439 return arg
3540 }
3641 }
3742
43+ // Correct <foo>:<bar> to <foo>://<bar>
3844 return `${ arg . slice ( 0 , firstColon + 1 ) } //${ arg . slice ( firstColon + 1 ) } `
3945}
4046
You can’t perform that action at this time.
0 commit comments