File tree Expand file tree Collapse file tree 4 files changed +19
-15
lines changed Expand file tree Collapse file tree 4 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ const LRU = require('lru-cache')
4
4
const hosts = require ( './hosts.js' )
5
5
const fromUrl = require ( './from-url.js' )
6
6
const parseUrl = require ( './parse-url.js' )
7
- const getProtocols = require ( './protocols.js' )
8
7
9
8
const cache = new LRU ( { max : 1000 } )
10
9
@@ -22,7 +21,15 @@ class GitHost {
22
21
}
23
22
24
23
static #gitHosts = { byShortcut : { } , byDomain : { } }
25
- static #protocols = getProtocols ( )
24
+ static #protocols = {
25
+ 'git+ssh:' : { name : 'sshurl' } ,
26
+ 'ssh:' : { name : 'sshurl' } ,
27
+ 'git+https:' : { name : 'https' , auth : true } ,
28
+ 'git:' : { auth : true } ,
29
+ 'http:' : { auth : true } ,
30
+ 'https:' : { auth : true } ,
31
+ 'git+http:' : { auth : true } ,
32
+ }
26
33
27
34
static addHost ( name , host ) {
28
35
GitHost . #gitHosts[ name ] = host
Original file line number Diff line number Diff line change 1
1
const url = require ( 'url' )
2
- const getProtocols = require ( './protocols.js' )
3
2
4
3
const lastIndexOfBefore = ( str , char , beforeChar ) => {
5
4
const startPosition = str . indexOf ( beforeChar )
@@ -73,7 +72,7 @@ const correctUrl = (giturl) => {
73
72
return giturl
74
73
}
75
74
76
- module . exports = ( giturl , protocols = getProtocols ( ) ) => {
77
- const withProtocol = correctProtocol ( giturl , protocols )
75
+ module . exports = ( giturl , protocols ) => {
76
+ const withProtocol = protocols ? correctProtocol ( giturl , protocols ) : giturl
78
77
return safeUrl ( withProtocol ) || safeUrl ( correctUrl ( withProtocol ) )
79
78
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,9 +2,16 @@ const t = require('tap')
2
2
const HostedGit = require ( '..' )
3
3
const parseUrl = require ( '../lib/parse-url.js' )
4
4
5
- t . test ( 'can parse git+ssh url by default ' , async t => {
5
+ t . test ( 'can parse git+ssh urls ' , async t => {
6
6
// https://github.com/npm/cli/issues/5278
7
7
const u = 'git+ssh://git@abc:frontend/utils.git#6d45447e0c5eb6cd2e3edf05a8c5a9bb81950c79'
8
8
t . ok ( parseUrl ( u ) )
9
9
t . ok ( HostedGit . parseUrl ( u ) )
10
10
} )
11
+
12
+ t . test ( 'can parse file urls' , async t => {
13
+ // https://github.com/npm/cli/pull/5758#issuecomment-1292753331
14
+ const u = 'file:../../../global-prefix/lib/node_modules/@myscope/bar'
15
+ t . ok ( parseUrl ( u ) )
16
+ t . ok ( HostedGit . parseUrl ( u ) )
17
+ } )
You can’t perform that action at this time.
0 commit comments