Use base url for commentlink
Bug: Issue 11344
Change-Id: I68aa21f81e88441f01b9386fdbf77fbb93810ec3
(cherry picked from commit 8e7bde0da1
)
This commit is contained in:
@@ -15,7 +15,9 @@ limitations under the License.
|
||||
-->
|
||||
|
||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||
|
||||
<script src="ba-linkify.js"></script>
|
||||
<script src="link-text-parser.js"></script>
|
||||
|
@@ -122,6 +122,24 @@ limitations under the License.
|
||||
assert.equal(linkEl.textContent, changeID);
|
||||
});
|
||||
|
||||
test('Change-Id pattern was parsed and linked with base url', function() {
|
||||
window.CANONICAL_PATH = '/r';
|
||||
|
||||
// "Change-Id:" pattern.
|
||||
const changeID = 'I11d6a37f5e9b5df0486f6c922d8836dfa780e03e';
|
||||
const prefix = 'Change-Id: ';
|
||||
element.content = prefix + changeID;
|
||||
|
||||
const textNode = element.$.output.childNodes[0];
|
||||
const linkEl = element.$.output.childNodes[1];
|
||||
assert.equal(textNode.textContent, prefix);
|
||||
const url = '/r/q/' + changeID;
|
||||
assert.equal(linkEl.target, '_blank');
|
||||
// Since url is a path, the host is added automatically.
|
||||
assert.isTrue(linkEl.href.endsWith(url));
|
||||
assert.equal(linkEl.textContent, changeID);
|
||||
});
|
||||
|
||||
test('Multiple matches', function() {
|
||||
element.content = 'Issue 3650\nIssue 3450';
|
||||
var linkEl1 = element.$.output.childNodes[0];
|
||||
|
@@ -96,6 +96,10 @@ GrLinkTextParser.prototype.addLink =
|
||||
return;
|
||||
}
|
||||
if (!this.hasOverlap(position, length, outputArray)) {
|
||||
const baseUrl = Gerrit.BaseUrlBehavior.getBaseUrl();
|
||||
if (!!baseUrl && href.startsWith('/') && !href.startsWith(baseUrl)) {
|
||||
href = baseUrl + href;
|
||||
}
|
||||
this.addItem(text, href, null, position, length, outputArray);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user