Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not URL encode slashes in project name for GitLab https URL #47

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions git-host-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var gitHosts = module.exports = {
'domain': 'gitlab.com',
'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}'
},
gist: {
Expand Down
2 changes: 2 additions & 0 deletions git-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ GitHost.prototype._fill = function (template, opts) {
var rawcommittish = vars.committish
var rawFragment = vars.fragment
var rawPath = vars.path
var rawProject = vars.project
Object.keys(vars).forEach(function (key) {
vars[key] = encodeURIComponent(vars[key])
})
Expand All @@ -43,6 +44,7 @@ GitHost.prototype._fill = function (template, opts) {
vars.fragment = vars.fragment ? vars.fragment : ''
vars['#path'] = rawPath ? '#' + this.hashformat(rawPath) : ''
vars['/path'] = vars.path ? '/' + vars.path : ''
vars.projectPath = rawProject.split('/').map(encodeURIComponent).join('/')
if (opts.noCommittish) {
vars['#committish'] = ''
vars['/tree/committish'] = ''
Expand Down
6 changes: 6 additions & 0 deletions test/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ test('fromUrl(gitlab url)', function (t) {
require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab')
require('./lib/standard-tests')(verify, 'www.gitlab.com', 'gitlab')

t.is(
HostedGit.fromUrl('gitlab:group/sub group1/subgroup2/repo').https(),
'git+https://gitlab.com/group/sub%20group1/subgroup2/repo.git',
'subgroups are delimited with slashes and url encoded (shortcut -> https)'
)

t.end()
})