New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Count all URLs in text as 23 characters flat, do not count domain part of usernames #4427
Conversation
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 256 instead of {2,}?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did copy-paste the regex. If you have a more authoritative regex, be my guest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 256 part is not a big issue, as all domain names are limited to 255 characters in practice.
However, the regexp for the TLD is [a-z]{2,6}
, which is wrong because TLDs are not limited to 6 characters. eg. .network
(used by mastodon.network)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by #4463.
TODO: