5 describe('parse(url)', function(){
6 it('should support git://*', function(){
7 var url = 'git://github.com/jamesor/mongoose-versioner';
8 parse(url).should.equal('https://github.com/jamesor/mongoose-versioner');
11 it('should support git://*.git', function(){
12 var url = 'git://github.com/treygriffith/cellar.git';
13 parse(url).should.equal('https://github.com/treygriffith/cellar');
16 it('should support https://*', function(){
17 var url = 'https://github.com/Empeeric/i18n-node';
18 parse(url).should.equal('https://github.com/Empeeric/i18n-node');
21 it('should support https://*.git', function(){
22 var url = 'https://jpillora@github.com/banchee/tranquil.git';
23 parse(url).should.equal('https://github.com/banchee/tranquil');
26 it('should return undefined on failure', function(){
27 var url = 'git://github.com/justgord/.git';
28 assert(null == parse(url));
31 it('should parse git@github.com:bcoe/thumbd.git', function() {
32 var url = 'git@github.com:bcoe/thumbd.git';
33 parse(url).should.eql('https://github.com/bcoe/thumbd');
36 it('should parse git@github.com:bcoe/thumbd.git#2.7.0', function() {
37 var url = 'git@github.com:bcoe/thumbd.git#2.7.0';
38 parse(url).should.eql('https://github.com/bcoe/thumbd');
41 it('should parse git+https://github.com/bcoe/thumbd.git', function() {
42 var url = 'git+https://github.com/bcoe/thumbd.git';
43 parse(url).should.eql('https://github.com/bcoe/thumbd');
46 it('should parse git+ssh://github.com/bcoe/thumbd.git', function() {
47 var url = 'git+ssh://github.com/bcoe/thumbd.git';
48 parse(url).should.eql('https://github.com/bcoe/thumbd');
51 it('should parse https://EastCloud@github.com/EastCloud/node-websockets.git', function() {
52 var url = 'https://EastCloud@github.com/EastCloud/node-websockets.git';
53 parse(url).should.eql('https://github.com/EastCloud/node-websockets');
58 it('should parse git@gist urls', function() {
59 var url = 'git@gist.github.com:3135914.git';
60 parse(url).should.equal('https://gist.github.com/3135914')
63 it('should parse https://gist urls', function() {
64 var url = 'https://gist.github.com/3135914.git';
65 parse(url).should.equal('https://gist.github.com/3135914')
68 // Handle arbitrary GitHub Enterprise domains.
70 it('should parse parse extra GHE urls provided', function() {
71 var url = 'git://github.example.com/treygriffith/cellar.git';
73 url, {extraBaseUrls: ['github.example.com']}
74 ).should.equal('https://github.example.com/treygriffith/cellar');
77 it('should parse GHE urls with multiple subdomains', function() {
78 var url = 'git://github.internal.example.com/treygriffith/cellar.git';
80 url, {extraBaseUrls: ['github.internal.example.com']}
81 ).should.equal('https://github.internal.example.com/treygriffith/cellar');
85 describe('re', function() {
86 it('should expose GitHub url parsing regex', function() {
87 parse.re.source.should.equal(
88 /^(?:https?:\/\/|git:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source