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

Use letter and number classes in tag replacements #368

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

askmeaboutlo0m
Copy link
Contributor

For Mastodon-alikes, Misskey, Bluesky and Twitter. Instead of replacing all non-English letters and non-Arabic digits with nothing and causing those tags to disappear, they now use proper Unicode character classes for letters and numbers that will allow other scripts through while still replacing punctuation and whatnot.

For Mastodon-alikes, Misskey, Bluesky and Twitter. Instead of replacing
all non-English letters and non-Arabic digits with nothing and causing
those tags to disappear, they now use proper Unicode character classes
for letters and numbers that will allow other scripts through while
still replacing punctuation and whatnot.
@askmeaboutlo0m askmeaboutlo0m changed the base branch from master to develop September 27, 2024 19:46
@@ -182,7 +182,9 @@ export class Bluesky extends Website {

formatTags(tags: string[]) {
return this.parseTags(
tags.map(tag => tag.replace(/[^a-z0-9]/gi, ' ')).map(tag => tag.split(' ').join('')),
tags
.map(tag => tag.replace(/[^\p{Letter}\p{Number}]/giu, ' '))
Copy link
Owner

Choose a reason for hiding this comment

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

q: is this a newer js feature? (and by newer I mean anything after 2018 since I haven't been able to keep up with all the new specs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uh, I didn't check, Perl had this since 2000 so I'd assumed that everyone that copied their regular expressions from there had it too. Looking it up, apparently it was introduced into JavaScript in 2015, so I guess they were 15 years late to the party, but still have had it for a while now.

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.

2 participants