Skip to content
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

Merged
merged 2 commits into from Jul 28, 2017

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Jul 28, 2017

TODO:

  • Backend validation adjusted
  • Tests
  • Web UI counter adjusted

@Gargron Gargron added the work in progress Not to be merged, currently being worked on label Jul 28, 2017
@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Jul 28, 2017

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)
Copy link
Member

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,}?

Copy link
Member Author

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

Copy link
Contributor

@progval progval Jul 29, 2017

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by #4463.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants