Merge "Fix linkification of CC= lines"
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index 8a9df82..44fe91a 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -26,7 +26,7 @@
// Maximum length for patch set descriptions.
const PATCH_DESC_MAX_LENGTH = 500;
- const REVIEWERS_REGEX = /^R=/gm;
+ const REVIEWERS_REGEX = /^(R|CC)=/gm;
const MIN_CHECK_INTERVAL_SECS = 0;
// These are the same as the breakpoint set in CSS. Make sure both are changed
@@ -917,8 +917,8 @@
_prepareCommitMsgForLinkify(msg) {
// TODO(wyatta) switch linkify sequence, see issue 5526.
// This is a zero-with space. It is added to prevent the linkify library
- // from including R= as part of the email address.
- return msg.replace(REVIEWERS_REGEX, 'R=\u200B');
+ // from including R= or CC= as part of the email address.
+ return msg.replace(REVIEWERS_REGEX, '$1=\u200B');
},
_getChangeDetail() {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
index 5d7062d..7250056 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
@@ -253,6 +253,10 @@
commitMessage = 'R=test@google.com\nR=test@google.com';
result = element._prepareCommitMsgForLinkify(commitMessage);
assert.equal(result, 'R=\u200Btest@google.com\nR=\u200Btest@google.com');
+
+ commitMessage = 'CC=test@google.com';
+ result = element._prepareCommitMsgForLinkify(commitMessage);
+ assert.equal(result, 'CC=\u200Btest@google.com');
}),
test('_computePatchSetCommentsString', () => {
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html
index 0042049..52a7de0 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text_test.html
@@ -193,6 +193,13 @@
assert.equal(element.$.output.innerHTML.match(/(R=<a)/g).length, 1);
});
+ test('CC=email labels link correctly', function() {
+ element.removeZeroWidthSpace = true;
+ element.content = 'CC=\u200Btest@google.com';
+ assert.equal(element.$.output.textContent, 'CC=test@google.com');
+ assert.equal(element.$.output.innerHTML.match(/(CC=<a)/g).length, 1);
+ });
+
test('overlapping links', function() {
element.config = {
b1: {
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-text/link-text-parser.js b/polygerrit-ui/app/elements/shared/gr-linked-text/link-text-parser.js
index e7ca50d..8a489f4 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-text/link-text-parser.js
+++ b/polygerrit-ui/app/elements/shared/gr-linked-text/link-text-parser.js
@@ -132,7 +132,7 @@
// TODO(wyatta) switch linkify sequence, see issue 5526.
if (this.removeZeroWidthSpace) {
// Remove the zero-width space added in gr-change-view.
- text = text.replace(/^R=\u200B/gm, 'R=');
+ text = text.replace(/^(CC|R)=\u200B/gm, '$1=');
}
if (href) {