Skip to content

Commit

Permalink
fix: support multiple directory (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore authored and fengmk2 committed Dec 12, 2018
1 parent a71915e commit 17a90af
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/giturl.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ exports.parse = function parse(sourceURL) {
var protocol = HTTPS_HOSTS[host] ? 'https' : 'http';

// p1/p2/.../pn[.xxx]
var url = item[2].split('/', 2).join('/');
var isContainGit = /\.git$/.test(sourceURL);
var url = isContainGit ? item[2] : item[2].split('/', 2).join('/');
return protocol + '://' + host + '/' + url;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"cov": "*",
"coveralls": "*",
"jshint": "*",
"mocha": "*",
"mocha": "2",
"mocha-lcov-reporter": "*",
"should": "3.3.1",
"travis-cov": "*"
Expand Down
1 change: 1 addition & 0 deletions test/giturl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('giturl.test.js', function () {
giturl.parse('git://gitlab.com/edp/logger.git').should.equal('http://gitlab.com/edp/logger');
giturl.parse('[email protected]:edp/logger.git').should.equal('http://gitlab.com/edp/logger');
giturl.parse('git://github.com/treygriffith/cellar.git').should.equal('https://github.com/treygriffith/cellar');
giturl.parse('[email protected]:frontend/arch/xxx.git').should.equal('http://gitlab.xxx.com/frontend/arch/xxx');
giturl.parse('https://github.com/banchee/tranquil.git').should.equal('https://github.com/banchee/tranquil');
giturl.parse('https://github.com/banchee/tranquil').should.equal('https://github.com/banchee/tranquil');
giturl.parse('http://github.com/banchee/tranquil.git').should.equal('https://github.com/banchee/tranquil');
Expand Down

0 comments on commit 17a90af

Please sign in to comment.