mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Refactor unifiedToNative function in emoji_utils
The unifiedToNative function in emoji_utils.ts has been refactored for cleaner coding practices. Lint disabling has been moved to a different part of the code, and type checking has been revised to specify that the input unified is of type Emoji['unified']. The function's variables have been updated to const for better securities against undesired changes.
This commit is contained in:
parent
1c4cf654d7
commit
3c7ccb2e62
1 changed files with 5 additions and 7 deletions
|
@ -34,22 +34,20 @@ const buildSearch = (data: Data) => {
|
||||||
return search.join(',');
|
return search.join(',');
|
||||||
};
|
};
|
||||||
|
|
||||||
/* eslint-disable */
|
|
||||||
|
|
||||||
const _JSON = JSON;
|
const _JSON = JSON;
|
||||||
|
|
||||||
const COLONS_REGEX = /^(?::([^:]+):)(?::skin-tone-(\d):)?$/;
|
const COLONS_REGEX = /^(?::([^:]+):)(?::skin-tone-(\d):)?$/;
|
||||||
const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
||||||
|
|
||||||
// @ts-expect-error
|
function unifiedToNative(unified: Emoji['unified']) {
|
||||||
function unifiedToNative(unified) {
|
const unicodes = unified?.split('-') ?? [];
|
||||||
let unicodes = unified.split('-'),
|
const codePoints = unicodes.map((u) => +`0x${u}`);
|
||||||
// @ts-expect-error
|
|
||||||
codePoints = unicodes.map((u) => `0x${u}`);
|
|
||||||
|
|
||||||
return String.fromCodePoint(...codePoints);
|
return String.fromCodePoint(...codePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
function sanitize(emoji) {
|
function sanitize(emoji) {
|
||||||
let {
|
let {
|
||||||
|
|
Loading…
Reference in a new issue