communications app, popup lib

This commit is contained in:
2023-04-08 11:46:20 +08:00
parent 449196b491
commit f85d4c9903
25 changed files with 746 additions and 279 deletions

View File

@ -34,7 +34,7 @@ function formatUrl(msg) {
//const urlArrray = str.match(urlReg);
const p = /(http|ftp|https):\/\/.+?(\s|\r\n|\r|\n|\"|\'|\*|$)/g;
const r = msg.match(p);
msg = htmlencode(msg);
msg = escapeHtml(msg);
if (r?.length > 0) {
const rs = [];
@ -50,7 +50,17 @@ function formatUrl(msg) {
}
}
return msg
return msg;
}
function escapeHtml(text) {
if (text == null) {
return '';
}
return String(text)
.replaceAll('&', '&')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.replaceAll('\r\n', '<br/>')
.replaceAll('\n', '<br/>')
.replaceAll(' ', '&nbsp;');
@ -61,5 +71,6 @@ export {
contains,
endsWith,
padStart,
formatUrl
formatUrl,
escapeHtml
}