SHA256
Обновить сервер и клиент для описания приложения
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// Текст сервера недоверенный: никакого HTML, только текст и HTTPS-ссылки.
|
||||
export function appendAboutText(container, text) {
|
||||
const value = String(text);
|
||||
let offset = 0;
|
||||
for (const match of value.matchAll(/https:\/\/[^\s<>"']+/gu)) {
|
||||
container.append(document.createTextNode(value.slice(offset, match.index)));
|
||||
try {
|
||||
const url = new URL(match[0]);
|
||||
if (url.protocol !== 'https:' || url.username || url.password) throw new Error('Invalid URL');
|
||||
const link = document.createElement('a');
|
||||
link.href = url.href;
|
||||
link.textContent = match[0];
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener noreferrer';
|
||||
container.append(link);
|
||||
} catch {
|
||||
container.append(document.createTextNode(match[0]));
|
||||
}
|
||||
offset = match.index + match[0].length;
|
||||
}
|
||||
container.append(document.createTextNode(value.slice(offset)));
|
||||
}
|
||||
Reference in New Issue
Block a user