Fix bug in which links preceeded text

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-05-11 13:59:45 +05:30
parent 3beaf88a8b
commit 051771397c

View file

@ -3,8 +3,8 @@ export function linkify(text, callback) {
const matches = text.matchAll(regex); const matches = text.matchAll(regex);
let curr = 0; let curr = 0;
for (let match of matches) { for (let match of matches) {
callback(match[0], true);
callback(text.slice(curr, match.index), false); callback(text.slice(curr, match.index), false);
callback(match[0], true);
const len = match[0].length; const len = match[0].length;
curr = match.index + len; curr = match.index + len;
} }