@@ -3,42 +3,43 @@ var HostedGit = require('../index')
3
3
var test = require ( 'tap' ) . test
4
4
5
5
test ( 'fromUrl(gist url)' , function ( t ) {
6
+ var proj = new Array ( 33 ) . join ( '2' )
6
7
function verify ( host , label , branch ) {
7
8
var hostinfo = HostedGit . fromUrl ( host )
8
9
var hash = branch ? '#' + branch : ''
9
10
t . ok ( hostinfo , label )
10
11
if ( ! hostinfo ) return
11
- t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/222 .git' + hash , label + ' -> https' )
12
- t . is ( hostinfo . git ( ) , 'git://gist.github.com/222 .git' + hash , label + ' -> git' )
13
- t . is ( hostinfo . browse ( ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) , label + ' -> browse' )
14
- t . is ( hostinfo . browse ( 'C' ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path)' )
15
- t . is ( hostinfo . browse ( 'C' , 'A' ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path, fragment)' )
16
- t . is ( hostinfo . bugs ( ) , 'https://gist.github.com/222' , label + ' -> bugs' )
17
- t . is ( hostinfo . docs ( ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) , label + ' -> docs' )
18
- t . is ( hostinfo . ssh ( ) , 'git@gist.github.com:/222 .git' + hash , label + ' -> ssh' )
19
- t . is ( hostinfo . sshurl ( ) , 'git+ssh://git@gist.github.com/222 .git' + hash , label + ' -> sshurl' )
20
- t . is ( hostinfo . shortcut ( ) , 'gist:222' + hash , label + ' -> shortcut' )
12
+ t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/' + proj + ' .git' + hash , label + ' -> https' )
13
+ t . is ( hostinfo . git ( ) , 'git://gist.github.com/' + proj + ' .git' + hash , label + ' -> git' )
14
+ t . is ( hostinfo . browse ( ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) , label + ' -> browse' )
15
+ t . is ( hostinfo . browse ( 'C' ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path)' )
16
+ t . is ( hostinfo . browse ( 'C' , 'A' ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path, fragment)' )
17
+ t . is ( hostinfo . bugs ( ) , 'https://gist.github.com/' + proj , label + ' -> bugs' )
18
+ t . is ( hostinfo . docs ( ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) , label + ' -> docs' )
19
+ t . is ( hostinfo . ssh ( ) , 'git@gist.github.com:/' + proj + ' .git' + hash , label + ' -> ssh' )
20
+ t . is ( hostinfo . sshurl ( ) , 'git+ssh://git@gist.github.com/' + proj + ' .git' + hash , label + ' -> sshurl' )
21
+ t . is ( hostinfo . shortcut ( ) , 'gist:' + proj + hash , label + ' -> shortcut' )
21
22
if ( hostinfo . user ) {
22
- t . is ( hostinfo . file ( 'C' ) , 'https://gist.githubusercontent.com/111/222 /raw/' + ( branch ? branch + '/' : '' ) + 'C' , label + ' -> file' )
23
- t . is ( hostinfo . tarball ( ) , 'https://gist.github.com/111/222 /archive/' + ( branch || 'master' ) + '.tar.gz' , label + ' -> tarball' )
23
+ t . is ( hostinfo . file ( 'C' ) , 'https://gist.githubusercontent.com/111/' + proj + ' /raw/' + ( branch ? branch + '/' : '' ) + 'C' , label + ' -> file' )
24
+ t . is ( hostinfo . tarball ( ) , 'https://gist.github.com/111/' + proj + ' /archive/' + ( branch || 'master' ) + '.tar.gz' , label + ' -> tarball' )
24
25
}
25
26
}
26
27
27
- verify ( 'git@gist.github.com:222 .git' , 'git@' )
28
- var hostinfo = HostedGit . fromUrl ( 'git@gist.github.com:/ef860c7z5e0de3179341 .git' )
28
+ verify ( 'git@gist.github.com:' + proj + ' .git', 'git@' )
29
+ var hostinfo = HostedGit . fromUrl ( 'git@gist.github.com:/c2b12db30a49324325a3781302668408 .git' )
29
30
if ( t . ok ( hostinfo , 'git@hex' ) ) {
30
- t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/ef860c7z5e0de3179341 .git' , 'git@hex -> https' )
31
+ t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/c2b12db30a49324325a3781302668408 .git' , 'git@hex -> https' )
31
32
}
32
- verify ( 'git@gist.github.com:/222 .git' , 'git@/' )
33
- verify ( 'git://gist.github.com/222' , 'git' )
34
- verify ( 'git://gist.github.com/222 .git' , 'git.git' )
35
- verify ( 'git://gist.github.com/222 #branch' , 'git#branch' , 'branch' )
36
- verify ( 'git://gist.github.com/222 .git#branch' , 'git.git#branch' , 'branch' )
33
+ verify ( 'git@gist.github.com:/' + proj + ' .git', 'git@/' )
34
+ verify ( 'git://gist.github.com/' + proj , 'git' )
35
+ verify ( 'git://gist.github.com/' + proj + ' .git', 'git.git' )
36
+ verify ( 'git://gist.github.com/' + proj + ' #branch', 'git#branch' , 'branch' )
37
+ verify ( 'git://gist.github.com/' + proj + ' .git#branch', 'git.git#branch' , 'branch' )
37
38
38
- require ( './lib/standard-tests' ) ( verify , 'gist.github.com' , 'gist' )
39
+ require ( './lib/standard-tests' ) ( verify , 'gist.github.com' , 'gist' , proj )
39
40
40
- verify ( HostedGit . fromUrl ( 'gist:111/222' ) . toString ( ) , 'round-tripped shortcut' )
41
- verify ( 'gist:222' , 'shortened shortcut' )
41
+ verify ( HostedGit . fromUrl ( 'gist:111/' + proj ) . toString ( ) , 'round-tripped shortcut' )
42
+ verify ( 'gist:' + proj , 'shortened shortcut' )
42
43
43
44
t . end ( )
44
45
} )
0 commit comments