Skip to content

Commit 06767f8

Browse files
committed
Merge pull request #5 from jeremyruppel/host
Include host in the result object
2 parents d86ee60 + 4506723 commit 06767f8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function parse(str) {
7979

8080
obj.branch = obj.branch || seg[2] || getBranch(obj.path, obj);
8181
var res = {};
82+
res.host = obj.host || 'github.com';
8283
res.owner = obj.owner || null;
8384
res.name = obj.name || null;
8485
res.repo = obj.repo;

test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,18 @@ describe('parse-github-url', function() {
176176
assert.equal(gh('https://github.com/repos/assemble/verb/zipball').name, 'verb');
177177
assert.equal(gh('https://github.com/repos/assemble/dot.repo/zipball').name, 'dot.repo');
178178
});
179+
it('should get the host:', function () {
180+
assert.equal(gh('git+https://github.com/assemble/verb.git').host, 'github.com');
181+
assert.equal(gh('git+ssh://github.com/assemble/verb.git').host, 'github.com');
182+
assert.equal(gh('git://github.com/assemble/verb').host, 'github.com');
183+
assert.equal(gh('git://github.com/assemble/verb.git').host, 'github.com');
184+
assert.equal(gh('git://github.one.com/assemble/verb.git').host, 'github.one.com');
185+
assert.equal(gh('git://github.one.two.com/assemble/verb.git').host, 'github.one.two.com');
186+
assert.equal(gh('https://github.com/assemble/verb').host, 'github.com');
187+
assert.equal(gh('https://github.one.com/assemble/verb').host, 'github.one.com');
188+
assert.equal(gh('https://github.one.two.com/assemble/verb').host, 'github.one.two.com');
189+
});
190+
it('should assume github.com is the host when not provided:', function () {
191+
assert.equal(gh('assemble/verb').host, 'github.com');
192+
});
179193
});

0 commit comments

Comments
 (0)