Skip to content

Commit 4c01a68

Browse files
committed
Merge branch 'bugfix/reencode-owner-and-repo-names' of github.com:lfcyja/git-url-parse into new-version
2 parents 638bcf4 + 85d4d30 commit 4c01a68

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,13 @@ function buildPath(obj) {
302302
case "bitbucket-server":
303303
return `scm/${obj.full_name}`;
304304
default:
305-
return `${obj.full_name}`;
305+
// Note: Re-encode the repository and owner names for hosting services that allow whitespace characters
306+
const encoded_full_name = obj.full_name
307+
.split('/')
308+
.map(x => encodeURIComponent(x))
309+
.join('/');
306310

311+
return encoded_full_name;
307312
}
308313
}
309314

test/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ tester.describe("parse urls", test => {
502502
var res = gitUrlParse("http://github.com/owner/name.git");
503503
res.user = "user";
504504
test.expect(res.toString()).toBe("http://[email protected]/owner/name.git");
505+
506+
var res = gitUrlParse("https://dev.azure.com/organization/owner%20with%20space/_git/repo%20with%20space")
507+
res.user = "pat"
508+
test.expect(res.toString()).toBe("https://[email protected]/organization/owner%20with%20space/_git/repo%20with%20space")
505509
});
506510

507511
// commits

0 commit comments

Comments
 (0)