diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index ceb1c5dea..ae43f7387 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4434,17 +4434,16 @@ } range = Linkify.makeRange(node, endNode, index, length); if (link = Linkify.regString.exec(text = range.toString())) { - if ((lIndex = link.index) !== index) { - range.setStart(node, lIndex); + if (lIndex = link.index) { + range.setStart(node, lIndex + index); } links.push([range, text]); } break; } else { - if (result = Linkify.regString.exec(result[0])) { - Linkify.regString.lastIndex = 0; - range = Linkify.makeRange(node, node, result.index, result.length); - links.push([range, result[0]]); + if (link = Linkify.regString.exec(result[0])) { + range = Linkify.makeRange(node, node, link.index, link.length); + links.push([range, link]); } } } diff --git a/builds/crx/script.js b/builds/crx/script.js index 279aa223f..062b61aa4 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4439,17 +4439,16 @@ } range = Linkify.makeRange(node, endNode, index, length); if (link = Linkify.regString.exec(text = range.toString())) { - if ((lIndex = link.index) !== index) { - range.setStart(node, lIndex); + if (lIndex = link.index) { + range.setStart(node, lIndex + index); } links.push([range, text]); } break; } else { - if (result = Linkify.regString.exec(result[0])) { - Linkify.regString.lastIndex = 0; - range = Linkify.makeRange(node, node, result.index, result.length); - links.push([range, result[0]]); + if (link = Linkify.regString.exec(result[0])) { + range = Linkify.makeRange(node, node, link.index, link.length); + links.push([range, link]); } } } diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 250dcd200..ef1684dce 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -69,16 +69,15 @@ Linkify = if length is endNode.data.length then test.lastIndex = 0 range = Linkify.makeRange node, endNode, index, length if link = Linkify.regString.exec text = range.toString() - if (lIndex = link.index) isnt index - range.setStart node, lIndex + if lIndex = link.index + range.setStart node, lIndex + index links.push [range, text] break else - if result = Linkify.regString.exec result[0] - Linkify.regString.lastIndex = 0 - range = Linkify.makeRange node, node, result.index, result.length - links.push [range, result[0]] + if link = Linkify.regString.exec result[0] + range = Linkify.makeRange node, node, link.index, link.length + links.push [range, link] for range in links.reverse() @nodes.links.push Linkify.makeLink range, @