fix #556 correct non-english hashtags #557
No reviewers
Labels
No Label
1000k
100k
10k
200k
20k
500k
50k
5k
75k
backend
blocked:design
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
P1
P2
P3
question
scope:intl
scope:nip
scope:query_tracing
scope:ux
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Kieran/snort#557
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "(deleted):patch-556"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was the problem?
Our code was taking only the first hashtag. We need to take all the hashtags from the content
How did I verify the fix?
I created a new event with similar text as the one in the issue #556 , using the new code.
New Event ID:
note1hrkkcwrlkm8hq0a2rfl5tksng62pug8arnn5qf27c0syg5gv0pcs2je6n9
New Event JSON
Screenshot of JSON Diff
@ -48,0 +46,4 @@
this.#replaceMention(m)
);
const hashTags = [...this.#content.matchAll(new RegExp(HashtagRegex, "g"))];
Maybe you can just add the
/g
to the regex?Done!
@ -45,3 +45,1 @@
this.#content = this.#content
.replace(/@n(pub|profile|event|ote|addr|)1[acdefghjklmnpqrstuvwxyz023456789]+/g, m => this.#replaceMention(m))
.replace(HashtagRegex, m => this.#replaceHashtag(m));
this.#content = this.#content.replace(/@n(pub|profile|event|ote|addr|)1[acdefghjklmnpqrstuvwxyz023456789]+/g, m =>
Does this work then? Seems like there is a flaw here which also might affect mentions?
Yes this seems to work without issues.
Just to ensure that I am not affecting the mentions, I tested with this note
https://snort.social/e/note190vnpkk5p3e9fq6xmpewr5kdm808esxdfymrqptzk7at00meuhyq2ekf03
The event JSON turned out to be as expected
The similar note, when tested on snort.social without this fix gives the following faulty JSON for the note https://snort.social/e/note134xyhwstlavjv644pafs7x0pkvlg0qa2sflx582nkd4wr9um0mwshth3s2
Looks like I messed up by pulling commits from main.
I will close this PR and create a new one soon
Pull request closed