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:
@@ -71,6 +71,10 @@ limitations under the License.
|
|||||||
match: 'test (.+)',
|
match: 'test (.+)',
|
||||||
html: '<a href="/r/awesomesauce">$1</a>',
|
html: '<a href="/r/awesomesauce">$1</a>',
|
||||||
},
|
},
|
||||||
|
anotatstartwithbaseurl: {
|
||||||
|
match: 'a test (.+)',
|
||||||
|
html: '[Lookup: <a href="/r/awesomesauce">$1</a>]',
|
||||||
|
},
|
||||||
disabledconfig: {
|
disabledconfig: {
|
||||||
match: 'foo:(.+)',
|
match: 'foo:(.+)',
|
||||||
link: 'https://google.com/search?q=$1',
|
link: 'https://google.com/search?q=$1',
|
||||||
@@ -214,6 +218,15 @@ limitations under the License.
|
|||||||
assert.equal(linkEl.textContent, 'foo');
|
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', () => {
|
test('hash html with base url', () => {
|
||||||
window.CANONICAL_PATH = '/r';
|
window.CANONICAL_PATH = '/r';
|
||||||
|
|
||||||
|
@@ -195,7 +195,7 @@
|
|||||||
function(html, position, length, outputArray) {
|
function(html, position, length, outputArray) {
|
||||||
if (this.hasOverlap(position, length, outputArray)) { return; }
|
if (this.hasOverlap(position, length, outputArray)) { return; }
|
||||||
if (!!this.baseUrl && html.match(/<a href=\"\//g) &&
|
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}\/`);
|
html = html.replace(/<a href=\"\//g, `<a href=\"${this.baseUrl}\/`);
|
||||||
}
|
}
|
||||||
this.addItem(null, null, html, position, length, outputArray);
|
this.addItem(null, null, html, position, length, outputArray);
|
||||||
|
Reference in New Issue
Block a user