blob: bad031b92690b7eba5cdc4f5a2818721e39e4300 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
var should = require('should');
var git = require('../lib/utils/git');
describe('Git', function() {
describe('URL parsing', function() {
it('should correctly validate git urls', function() {
// HTTPS
git.isUrl('git+https://github.com/Hello/world.git').should.be.ok;
// SSH
git.isUrl('git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1').should.be.ok;
// Non valid
git.isUrl('https://github.com/Hello/world.git').should.not.be.ok;
git.isUrl('README.md').should.not.be.ok;
});
it('should parse HTTPS urls', function() {
var parts = git.parseUrl('git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md');
should.exist(parts);
parts.host.should.be.equal('https://gist.github.com/69ea4542e4c8967d2fa7.git');
parts.ref.should.be.equal('master');
parts.filepath.should.be.equal('test.md');
});
it('should parse HTTPS urls with a reference', function() {
var parts = git.parseUrl('git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md#1.0.0');
should.exist(parts);
parts.host.should.be.equal('https://gist.github.com/69ea4542e4c8967d2fa7.git');
parts.ref.should.be.equal('1.0.0');
parts.filepath.should.be.equal('test.md');
});
it('should parse SSH urls', function() {
var parts = git.parseUrl('git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1');
should.exist(parts);
parts.host.should.be.equal('git@github.com:GitbookIO/gitbook.git');
parts.ref.should.be.equal('e1594cde2c32e4ff48f6c4eff3d3d461743d74e1');
parts.filepath.should.be.equal('directory/README.md');
});
});
});
|