Do not encode "," when redirecting /projects/ -> /repos/

Bug: Issue 11096
Change-Id: Id3eb92254f25e8e86568be50c11e60d1a6835af9
This commit is contained in:
Paladox none 2019-07-05 12:58:23 +00:00
parent ec43544188
commit 87f9960f0d
2 changed files with 30 additions and 3 deletions

View File

@ -1092,11 +1092,16 @@
},
_handleProjectsOldRoute(data) {
let params = '';
if (data.params[1]) {
this._redirect('/admin/repos/' + encodeURIComponent(data.params[1]));
} else {
this._redirect('/admin/repos');
params = encodeURIComponent(data.params[1]);
if (data.params[1].includes(',')) {
params =
encodeURIComponent(data.params[1]).replace('%2C', ',');
}
}
this._redirect(`/admin/repos/${params}`);
},
_handleRepoCommandsRoute(data) {

View File

@ -1100,6 +1100,28 @@ limitations under the License.
});
suite('repo routes', () => {
test('_handleProjectsOldRoute', () => {
const data = {params: {}};
element._handleProjectsOldRoute(data);
assert.isTrue(redirectStub.calledOnce);
assert.equal(redirectStub.lastCall.args[0], '/admin/repos/');
});
test('_handleProjectsOldRoute test', () => {
const data = {params: {1: 'test'}};
element._handleProjectsOldRoute(data);
assert.isTrue(redirectStub.calledOnce);
assert.equal(redirectStub.lastCall.args[0], '/admin/repos/test');
});
test('_handleProjectsOldRoute test,branches', () => {
const data = {params: {1: 'test,branches'}};
element._handleProjectsOldRoute(data);
assert.isTrue(redirectStub.calledOnce);
assert.equal(
redirectStub.lastCall.args[0], '/admin/repos/test,branches');
});
test('_handleRepoRoute', () => {
const data = {params: {0: 4321}};
assertDataToParams(data, '_handleRepoRoute', {