FIX: Do not perform link lookup for replaced links (#14742)
A link that was added because a watched word was replaced could create a notice if the same link was present before.
This commit is contained in:
parent
efc23b6a8d
commit
148ee1d162
|
@ -505,6 +505,11 @@ export default Controller.extend({
|
||||||
$links.each((idx, l) => {
|
$links.each((idx, l) => {
|
||||||
const href = l.href;
|
const href = l.href;
|
||||||
if (href && href.length) {
|
if (href && href.length) {
|
||||||
|
// skip links added by watched words
|
||||||
|
if (l.dataset.word !== undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// skip links in quotes and oneboxes
|
// skip links in quotes and oneboxes
|
||||||
for (let element = l; element; element = element.parentElement) {
|
for (let element = l; element; element = element.parentElement) {
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -139,6 +139,7 @@ export const DEFAULT_LIST = [
|
||||||
`a.inline-onebox`,
|
`a.inline-onebox`,
|
||||||
`a.inline-onebox-loading`,
|
`a.inline-onebox-loading`,
|
||||||
"a[data-bbcode]",
|
"a[data-bbcode]",
|
||||||
|
"a[data-word]",
|
||||||
"a[name]",
|
"a[name]",
|
||||||
"a[rel=nofollow]",
|
"a[rel=nofollow]",
|
||||||
"a[rel=ugc]",
|
"a[rel=ugc]",
|
||||||
|
|
|
@ -32,6 +32,8 @@ function findAllMatches(text, matchers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setup(helper) {
|
export function setup(helper) {
|
||||||
|
const opts = helper.getOptions();
|
||||||
|
|
||||||
helper.registerPlugin((md) => {
|
helper.registerPlugin((md) => {
|
||||||
const matchers = [];
|
const matchers = [];
|
||||||
|
|
||||||
|
@ -139,6 +141,9 @@ export function setup(helper) {
|
||||||
if (htmlLinkLevel === 0 && state.md.validateLink(url)) {
|
if (htmlLinkLevel === 0 && state.md.validateLink(url)) {
|
||||||
token = new state.Token("link_open", "a", 1);
|
token = new state.Token("link_open", "a", 1);
|
||||||
token.attrs = [["href", url]];
|
token.attrs = [["href", url]];
|
||||||
|
if (opts.discourse.previewing) {
|
||||||
|
token.attrs.push(["data-word", ""]);
|
||||||
|
}
|
||||||
token.level = level++;
|
token.level = level++;
|
||||||
token.markup = "linkify";
|
token.markup = "linkify";
|
||||||
token.info = "auto";
|
token.info = "auto";
|
||||||
|
|
Loading…
Reference in New Issue