Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix short tokens in getEmojiByShortcode (#90)
* fix: fix short tokens in getEmojiByShortcode * fix: add comment
- Loading branch information
1 parent
7c3f9fa
commit 992ac10
Showing
5 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { MIN_SEARCH_TEXT_LENGTH } from '../../shared/constants' | ||
|
||
// This is an extra step in addition to extractTokens(). The difference here is that we expect | ||
// the input to have already been run through extractTokens(). This is useful for cases like | ||
// emoticons, where we don't want to do any tokenization (because it makes no sense to split up | ||
// ">:)" by the colon) but we do want to lowercase it to have consistent search results, so that | ||
// the user can type ':P' or ':p' and still get the same result. | ||
export function normalizeTokens (str) { | ||
return str | ||
.filter(Boolean) | ||
.map(_ => _.toLowerCase()) | ||
.filter(_ => _.length >= MIN_SEARCH_TEXT_LENGTH) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters