Remove unused processName util and twemoji dependency (#1683)

## Description:
This PR removes the unused `processName` utility function from `Util.ts`
and its dependency, the `twemoji` package.

The `processName` function has been commented out and non-operational
for approximately 9 months. This cleanup removes the dead code. As a
result, the `twemoji` npm package is no longer needed and has been
removed from the project's dependencies, which slightly reduces the
overall dependency footprint.

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [X] I have read and accepted the CLA agreement (only required once).

## Please put your Discord username so you can be contacted if a bug or
regression is found:

aaa4xu
This commit is contained in:
Aleksey Orekhovsky
2025-08-02 12:53:36 +07:00
committed by GitHub
parent 999fd9157c
commit aa6bc42854
4 changed files with 2 additions and 99 deletions
-34
View File
@@ -1,6 +1,5 @@
import DOMPurify from "dompurify";
import { customAlphabet } from "nanoid";
import twemoji from "twemoji";
import { Cell, Unit } from "./game/Game";
import { GameMap, TileRef } from "./game/GameMap";
import {
@@ -142,39 +141,6 @@ export function sanitize(name: string): string {
.replace(/[^\p{L}\p{N}\s\p{Emoji}\p{Emoji_Component}[\]_]/gu, "");
}
export function processName(name: string): string {
// First sanitize the raw input - strip everything except text and emojis
const sanitizedName = sanitize(name);
// Process emojis with twemoji
const withEmojis = twemoji.parse(sanitizedName, {
base: "https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/",
folder: "svg",
ext: ".svg",
});
// Add CSS styles inline to the wrapper span
const styledHTML = `
<span class="player-name" style="
display: inline-flex;
align-items: center;
gap: 0.25rem;
font-weight: 500;
vertical-align: middle;
">
${withEmojis}
</span>
`;
// Add CSS for the emoji images
const withEmojiStyles = styledHTML.replace(
/<img/g,
'<img style="height: 1.2em; width: 1.2em; vertical-align: -0.2em; margin: 0 0.05em 0 0.1em;"',
);
// Sanitize the final HTML, allowing styles and specific attributes
return onlyImages(withEmojiStyles);
}
export function onlyImages(html: string) {
return DOMPurify.sanitize(html, {
ALLOWED_TAGS: ["span", "img"],
+1 -1
View File
@@ -112,7 +112,7 @@ export class PlayerImpl implements Player {
this._name = sanitizeUsername(playerInfo.name);
this._troops = toInt(startTroops);
this._gold = 0n;
this._displayName = this._name; // processName(this._name)
this._displayName = this._name;
this._pseudo_random = new PseudoRandom(simpleHash(this.playerInfo.id));
}