Support links in posts (expanded automatically as detected in clear text)
This commit is contained in:
parent
ab8db4cf83
commit
ee75bdca9d
|
@ -152,6 +152,16 @@ app.post = {
|
|||
}
|
||||
}
|
||||
value = html2text(value);
|
||||
const urlmatches = value.match(/https?:\/\/[^\s\"]+/g);
|
||||
if (urlmatches !== undefined && urlmatches !== null) {
|
||||
for (var i = 0; i < urlmatches.length; i++) {
|
||||
try { new URL(urlmatches[i]).href.length > 0 }
|
||||
catch (e) { continue; }
|
||||
const modurl = urlmatches[i].replace(/^https?:\/\//,'');
|
||||
value = value.replaceAll(urlmatches[i], '<a class="link" href="'+
|
||||
htmlescape(urlmatches[i])+'">'+htmlescape(modurl)+'</a>');
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < replaceAfter.length; i++) {
|
||||
const it = replaceAfter[i];
|
||||
value = value.replaceAll(it[0], it[1]);
|
||||
|
|
Loading…
Reference in New Issue