Slightly more accurate content length

pull/354/merge
Lim Chee Aun 2023-12-16 16:05:03 +08:00
rodzic 4c7c518d4d
commit ec4320d53e
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -2,5 +2,10 @@ const div = document.createElement('div');
export default function htmlContentLength(html) {
if (!html) return 0;
div.innerHTML = html;
// .invisible spans for links
// e.g. <span class="invisible">https://</span>mastodon.social
div.querySelectorAll('.invisible').forEach((el) => {
el.remove();
});
return div.innerText.length;
}