s/var/let/

This commit is contained in:
Simon Ser
2021-06-10 18:11:11 +02:00
parent 4db845a4b1
commit 8972130252
20 changed files with 481 additions and 479 deletions

View File

@@ -4,12 +4,12 @@ function linkifyChannel(text, transformChannel) {
// Don't match punctuation at the end of the channel name
const channelRegex = /(?:^|\s)(#[^\s]+[^\s.?!():;,])/gid;
var children = [];
var match;
var last = 0;
let children = [];
let match;
let last = 0;
while ((match = channelRegex.exec(text)) !== null) {
var channel = match[1];
var [start, end] = match.indices[1];
let channel = match[1];
let [start, end] = match.indices[1];
children.push(text.substring(last, start));
children.push(transformChannel(channel));
@@ -34,20 +34,20 @@ export default function linkify(text, onChannelClick) {
>${channel}</a>`;
}
var links = anchorme.list(text);
let links = anchorme.list(text);
var children = [];
var last = 0;
let children = [];
let last = 0;
links.forEach((match) => {
const prefix = text.substring(last, match.start)
children.push(...linkifyChannel(prefix, transformChannel));
var proto = match.protocol || "https://";
let proto = match.protocol || "https://";
if (match.isEmail) {
proto = "mailto:";
}
var url = match.string;
let url = match.string;
if (!url.startsWith(proto)) {
url = proto + url;
}