1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-13 06:09:08 +09:00
YuruToot/app/javascript/mastodon/features/compose/util/counter.js

8 lines
310 B
JavaScript
Raw Normal View History

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');
};