mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Pull callback args into variables
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
9d898bdf47
commit
55b7c55efe
@ -4,12 +4,14 @@ 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(text.slice(curr, match.index), false);
|
const precedingText = text.slice(curr, match.index);
|
||||||
|
callback(precedingText, false);
|
||||||
callback(match[0], true);
|
callback(match[0], true);
|
||||||
const len = match[0].length;
|
const len = match[0].length;
|
||||||
curr = match.index + len;
|
curr = match.index + len;
|
||||||
}
|
}
|
||||||
callback(text.slice(curr), false);
|
const remainingText = text.slice(curr);
|
||||||
|
callback(remainingText, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tests() {
|
export function tests() {
|
||||||
|
Loading…
Reference in New Issue
Block a user