diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 9baed19bb..4b80565ec 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4450,7 +4450,7 @@ } Linkify.regString.lastIndex = 0; if (match) { - links.push(Linkify.seek(snapshot, node, match, i)); + links.push(Linkify.seek(snapshot, post, node, match, i)); } _ref = links.reverse(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -4458,8 +4458,8 @@ Linkify.makeLink(range, post); } }, - seek: function(snapshot, node, match, i) { - var data, link, next, range, result; + seek: function(snapshot, post, node, match, i) { + var data, index, link, next, range, result; link = match[0]; range = document.createRange(); @@ -4468,7 +4468,10 @@ node = next; data = node.data; if (result = /[\s'"]/.exec(data)) { - range.setEnd(node, result.index); + index = result.index; + range.setEnd(node, index); + Linkify.regString.lastIndex = index; + Linkify.gatherLinks(snapshot, post, node, i); } } if (range.collapsed) { diff --git a/builds/crx/script.js b/builds/crx/script.js index d967cac01..60987bcda 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4455,7 +4455,7 @@ } Linkify.regString.lastIndex = 0; if (match) { - links.push(Linkify.seek(snapshot, node, match, i)); + links.push(Linkify.seek(snapshot, post, node, match, i)); } _ref = links.reverse(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -4463,8 +4463,8 @@ Linkify.makeLink(range, post); } }, - seek: function(snapshot, node, match, i) { - var data, link, next, range, result; + seek: function(snapshot, post, node, match, i) { + var data, index, link, next, range, result; link = match[0]; range = document.createRange(); @@ -4473,7 +4473,10 @@ node = next; data = node.data; if (result = /[\s'"]/.exec(data)) { - range.setEnd(node, result.index); + index = result.index; + range.setEnd(node, index); + Linkify.regString.lastIndex = index; + Linkify.gatherLinks(snapshot, post, node, i); } } if (range.collapsed) { diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 5da99d362..8996da4bd 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -84,14 +84,14 @@ Linkify = Linkify.regString.lastIndex = 0 if match - links.push Linkify.seek snapshot, node, match, i + links.push Linkify.seek snapshot, post, node, match, i for range in links.reverse() Linkify.makeLink range, post return - seek: (snapshot, node, match, i) -> + seek: (snapshot, post, node, match, i) -> link = match[0] range = document.createRange() range.setStart node, match.index @@ -100,7 +100,10 @@ Linkify = node = next data = node.data if result = /[\s'"]/.exec data - range.setEnd node, result.index + {index} = result + range.setEnd node, index + Linkify.regString.lastIndex = index + Linkify.gatherLinks snapshot, post, node, i if range.collapsed range.setEndAfter node