From ea6ef1124d957172da30528edb763cacd70782c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C5=82gorzata=20=28Gosia=29?= <143265463+malgokiel@users.noreply.github.com> Date: Wed, 10 Sep 2025 17:32:30 +0200 Subject: [PATCH] fix: handle apostrophes for names ending in x (#4343) * fix: handle apostrophes for names ending in x * review --------- Co-authored-by: Alexandr --- src/cards/stats.js | 4 +--- tests/renderStatsCard.test.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cards/stats.js b/src/cards/stats.js index 5b7f0d26..402e86fb 100644 --- a/src/cards/stats.js +++ b/src/cards/stats.js @@ -254,9 +254,7 @@ const renderStatsCard = (stats, options = {}) => { theme, }); - const apostrophe = ["x", "s"].includes(name.slice(-1).toLocaleLowerCase()) - ? "" - : "s"; + const apostrophe = /s$/i.test(name.trim()) ? "" : "s"; const i18n = new I18n({ locale, translations: statCardLocales({ name, apostrophe }), diff --git a/tests/renderStatsCard.test.js b/tests/renderStatsCard.test.js index dab0f861..12640fdb 100644 --- a/tests/renderStatsCard.test.js +++ b/tests/renderStatsCard.test.js @@ -71,7 +71,7 @@ describe("Test renderStatsCard", () => { document.body.innerHTML = renderStatsCard({ ...stats, name: "Felix" }); expect(document.getElementsByClassName("header")[0].textContent).toBe( - "Felix' GitHub Stats", + "Felix's GitHub Stats", ); });