Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Fix regex in link-text-parser

Change-Id: I645413967c12310e7dbf610bce4867446d66281f
This commit is contained in:
Paladox
2019-09-30 17:08:02 +01:00
2 changed files with 14 additions and 1 deletions

View File

@@ -71,6 +71,10 @@ limitations under the License.
match: 'test (.+)',
html: '<a href="/r/awesomesauce">$1</a>',
},
anotatstartwithbaseurl: {
match: 'a test (.+)',
html: '[Lookup: <a href="/r/awesomesauce">$1</a>]',
},
disabledconfig: {
match: 'foo:(.+)',
link: 'https://google.com/search?q=$1',
@@ -214,6 +218,15 @@ limitations under the License.
assert.equal(linkEl.textContent, 'foo');
});
test('a is not at start', () => {
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', () => {
window.CANONICAL_PATH = '/r';

View File

@@ -195,7 +195,7 @@
function(html, position, length, outputArray) {
if (this.hasOverlap(position, length, outputArray)) { return; }
if (!!this.baseUrl && html.match(/<a href=\"\//g) &&
!new RegExp(`^<a href="${this.baseUrl}`, 'g').test(html)) {
!new RegExp(`<a href="${this.baseUrl}`, 'g').test(html)) {
html = html.replace(/<a href=\"\//g, `<a href=\"${this.baseUrl}\/`);
}
this.addItem(null, null, html, position, length, outputArray);