diff --git a/git-host-info.js b/git-host-info.js index 698924d..94cd176 100644 --- a/git-host-info.js +++ b/git-host-info.js @@ -24,7 +24,8 @@ var gitHosts = module.exports = { 'treepath': 'tree', 'bugstemplate': 'https://{domain}/{user}/{project}/issues', 'httpstemplate': 'git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}', - 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}' + 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}', + 'pathmatch': /^[/]([^/]+)[/](.+?)(?:[.]git|[/])?$/ }, gist: { 'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ], diff --git a/git-host.js b/git-host.js index d6dd9c0..7fe8b44 100644 --- a/git-host.js +++ b/git-host.js @@ -52,7 +52,7 @@ GitHost.prototype._fill = function (template, opts) { var rawProject = vars.project Object.keys(vars).forEach(function (key) { var value = vars[key] - if (key === 'path' && typeof value === 'string') { + if ((key === 'path' || key === 'project') && typeof value === 'string') { vars[key] = value.split('/').map(function (pathComponent) { return encodeURIComponent(pathComponent) }).join('/') diff --git a/test/gitlab.js b/test/gitlab.js index 36e6307..dd72a11 100644 --- a/test/gitlab.js +++ b/test/gitlab.js @@ -28,6 +28,15 @@ test('fromUrl(gitlab url)', function (t) { require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab') require('./lib/standard-tests')(verify, 'www.gitlab.com', 'gitlab') + const subsShort = HostedGit.fromUrl('gitlab:adpt/starters/hello-node') + const subsFull = HostedGit.fromUrl('git+https://gitlab.com/adpt/starters/hello-node.git') + t.ok(subsShort) + t.equal(subsShort.https(), 'git+https://gitlab.com/adpt/starters/hello-node.git') + t.equal(subsShort.ssh(), 'git@gitlab.com:adpt/starters/hello-node.git') + t.ok(subsFull) + t.equal(subsFull.https(), 'git+https://gitlab.com/adpt/starters/hello-node.git') + t.equal(subsFull.ssh(), 'git@gitlab.com:adpt/starters/hello-node.git') + t.is( HostedGit.fromUrl('gitlab:group/sub group1/subgroup2/repo').https(), 'git+https://gitlab.com/group/sub%20group1/subgroup2/repo.git',