mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-27 15:01:36 +01:00
53b2b1b238
* Count all URLs in text as 23 characters flat, do not count domain part of usernames * Add new status text counting logic to web UI
7 lines
310 B
JavaScript
7 lines
310 B
JavaScript
const urlPlaceholder = 'xxxxxxxxxxxxxxxxxxxxxxx';
|
|
|
|
export function countableText(inputText) {
|
|
return inputText
|
|
.replace(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g, urlPlaceholder)
|
|
.replace(/(?:^|[^\/\w])@(([a-z0-9_]+)@[a-z0-9\.\-]+)/ig, '@$2');
|
|
};
|