#222 - Encode branch name on requests to avoid errors with special chars

This commit is contained in:
Luis Correia 2017-02-03 15:10:27 +00:00
parent 679634afec
commit 471b26a9d5

View File

@ -331,20 +331,20 @@ export default class API {
} }
patchRef(type, name, sha) { patchRef(type, name, sha) {
return this.request(`${ this.repoURL }/git/refs/${ type }/${ name }`, { return this.request(`${ this.repoURL }/git/refs/${ type }/${ encodeURIComponent(name) }`, {
method: "PATCH", method: "PATCH",
body: JSON.stringify({ sha }), body: JSON.stringify({ sha }),
}); });
} }
deleteRef(type, name, sha) { deleteRef(type, name, sha) {
return this.request(`${ this.repoURL }/git/refs/${ type }/${ name }`, { return this.request(`${ this.repoURL }/git/refs/${ type }/${ encodeURIComponent(name) }`, {
method: "DELETE", method: "DELETE",
}); });
} }
getBranch(branch = this.branch) { getBranch(branch = this.branch) {
return this.request(`${ this.repoURL }/branches/${ branch }`); return this.request(`${ this.repoURL }/branches/${ encodeURIComponent(branch) }`);
} }
createBranch(branchName, sha) { createBranch(branchName, sha) {