Double-encode project name and branch links
Double-encode project name and branch links in change list view to work
around known pagejs library issue (see Issue 4255).
Bug: Issue 4502
Change-Id: Ic7ba5bab926e7a4033ecbb7170993b25c1fbf31c
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
index 90b2e1d..a43f564 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
@@ -108,11 +108,15 @@
},
_computeProjectURL: function(project) {
- return '/q/status:open+project:' + project;
+ // @see Issue 4255.
+ return '/q/status:open+project:' +
+ encodeURIComponent(encodeURIComponent(project));
},
_computeProjectBranchURL: function(project, branch) {
- return '/q/status:open+project:' + project + '+branch:' + branch;
+ // @see Issue 4255.
+ return this._computeProjectURL(project) +
+ '+branch:' + encodeURIComponent(encodeURIComponent(branch));
},
});
})();
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
index b7c0853..d2e6028 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
@@ -120,12 +120,12 @@
assert.equal(element._computeLabelValue(
{labels: {Verified: {rejected: true}}}, 'Verified'), '✕');
- assert.equal(element._computeProjectURL('combustible-stuff'),
- '/q/status:open+project:combustible-stuff');
+ assert.equal(element._computeProjectURL('combustible/stuff'),
+ '/q/status:open+project:combustible%252Fstuff');
assert.equal(element._computeProjectBranchURL(
- 'combustible-stuff', 'lemons'),
- '/q/status:open+project:combustible-stuff+branch:lemons');
+ 'combustible-stuff', 'le/mons'),
+ '/q/status:open+project:combustible-stuff+branch:le%252Fmons');
element.change = {_number: 42};
assert.equal(element.changeURL, '/c/42/');