fix: fix short tokens in getEmojiByShortcode #90
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #88
The issue here is that shortcodes like
smiling_face_with_3_hearts
contain a short string,3
, which is not indexed in the search tokens. We also have problems with shortcodes likev
(:v:) where there are no usual shortcodes at all.Of course the easiest solution here would be to create an IDB index on shortcodes. However, this seems like a wasteful use of disk space to me, as 1)
getEmojiByShortcode()
is not always used, and 2) all shortcodes become tokens that are indexed for searching anyway.So I'm going to keep the current system of filtering the database using the shortcode broken up into search tokens, while also adding special cases for tokens like
3
orv
(which requires a full database scan – reasonable IMO given that so few shortcodes are like this).