Encode repo names when generating URLs
Bug: Issue 9598 Change-Id: If87ce3564d4726bea0756bf8934e5e4c2ac9fe04
This commit is contained in:
@@ -396,7 +396,8 @@
|
|||||||
suffix += ',edit';
|
suffix += ',edit';
|
||||||
}
|
}
|
||||||
if (params.project) {
|
if (params.project) {
|
||||||
return `/c/${params.project}/+/${params.changeNum}${suffix}`;
|
const encodedProject = this.encodeURL(params.project, true);
|
||||||
|
return `/c/${encodedProject}/+/${params.changeNum}${suffix}`;
|
||||||
} else {
|
} else {
|
||||||
return `/c/${params.changeNum}${suffix}`;
|
return `/c/${params.changeNum}${suffix}`;
|
||||||
}
|
}
|
||||||
@@ -462,7 +463,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.project) {
|
if (params.project) {
|
||||||
return `/c/${params.project}/+/${params.changeNum}${suffix}`;
|
const encodedProject = this.encodeURL(params.project, true);
|
||||||
|
return `/c/${encodedProject}/+/${params.changeNum}${suffix}`;
|
||||||
} else {
|
} else {
|
||||||
return `/c/${params.changeNum}${suffix}`;
|
return `/c/${params.changeNum}${suffix}`;
|
||||||
}
|
}
|
||||||
|
@@ -283,6 +283,16 @@ limitations under the License.
|
|||||||
'/c/test/+/1234/5..10?revert&foo=bar');
|
'/c/test/+/1234/5..10?revert&foo=bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('change with repo name encoding', () => {
|
||||||
|
const params = {
|
||||||
|
view: Gerrit.Nav.View.CHANGE,
|
||||||
|
changeNum: '1234',
|
||||||
|
project: 'x+/y+/z+/w',
|
||||||
|
};
|
||||||
|
assert.equal(element._generateUrl(params),
|
||||||
|
'/c/x%252B/y%252B/z%252B/w/+/1234');
|
||||||
|
});
|
||||||
|
|
||||||
test('diff', () => {
|
test('diff', () => {
|
||||||
const params = {
|
const params = {
|
||||||
view: Gerrit.Nav.View.DIFF,
|
view: Gerrit.Nav.View.DIFF,
|
||||||
@@ -317,6 +327,18 @@ limitations under the License.
|
|||||||
'/c/test/+/42/2/file.cpp#b123');
|
'/c/test/+/42/2/file.cpp#b123');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('diff with repo name encoding', () => {
|
||||||
|
const params = {
|
||||||
|
view: Gerrit.Nav.View.DIFF,
|
||||||
|
changeNum: '42',
|
||||||
|
path: 'x+y/path.cpp',
|
||||||
|
patchNum: 12,
|
||||||
|
project: 'x+/y',
|
||||||
|
};
|
||||||
|
assert.equal(element._generateUrl(params),
|
||||||
|
'/c/x%252B/y/+/42/12/x%252By/path.cpp');
|
||||||
|
});
|
||||||
|
|
||||||
test('edit', () => {
|
test('edit', () => {
|
||||||
const params = {
|
const params = {
|
||||||
view: Gerrit.Nav.View.EDIT,
|
view: Gerrit.Nav.View.EDIT,
|
||||||
|
Reference in New Issue
Block a user