From 69cbcb1c6c6d7ad77e25ef9f88aa97f8b91a6e7c Mon Sep 17 00:00:00 2001 From: Paladox none Date: Mon, 30 Sep 2019 12:45:58 +0000 Subject: [PATCH] Fix regex in link-text-parser Change-Id: Idccdf04073367dd912fec35f902977e2b39f26d8 --- .../shared/gr-linked-text/gr-linked-text_test.html | 13 +++++++++++++ .../shared/gr-linked-text/link-text-parser.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) 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 f9b663cb36..db030119d3 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 @@ -69,6 +69,10 @@ limitations under the License. match: 'test (.+)', html: '$1', }, + anotatstartwithbaseurl: { + match: 'a test (.+)', + html: '[Lookup: $1]', + }, disabledconfig: { match: 'foo:(.+)', link: 'https://google.com/search?q=$1', @@ -212,6 +216,15 @@ limitations under the License. assert.equal(linkEl.textContent, 'foo'); }); + test('a is not at start', function() { + window.CANONICAL_PATH = '/r'; + + element.content = 'a test foo'; + const linkEl = element.$.output.childNodes[1]; + assert.isTrue(linkEl.href.endsWith('/r/awesomesauce')); + assert.equal(linkEl.textContent, 'foo'); + }); + test('hash html with base url', function() { window.CANONICAL_PATH = '/r'; 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 1afcc30fd4..f5b3824704 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 @@ -109,7 +109,7 @@ GrLinkTextParser.prototype.addHTML = function(html, position, length, outputArray) { if (!this.hasOverlap(position, length, outputArray)) { if (!!this.baseUrl && html.match(/