fix: preserve /citizens path in i18n URL rewriting

This commit is contained in:
2026-02-15 00:14:54 +03:00
parent e93cb143e2
commit 0f8541b6f5
3 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "pezkuwi-telegram-miniapp",
"version": "1.0.197",
"version": "1.0.198",
"type": "module",
"description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards",
"author": "Pezkuwichain Team",
+8 -3
View File
@@ -139,9 +139,14 @@ export function LanguageProvider({ children }: LanguageProviderProps) {
document.documentElement.lang = lang === 'krd' ? 'ku' : lang;
document.documentElement.dir = isRTL ? 'rtl' : 'ltr';
// Ensure URL has language prefix (preserve query params like ?page=citizen)
const firstSegment = window.location.pathname.split('/').filter(Boolean)[0];
if (!firstSegment || !VALID_LANGS.includes(firstSegment as LanguageCode)) {
// Ensure URL has language prefix (preserve query params and special paths)
const pathSegments = window.location.pathname.split('/').filter(Boolean);
const firstSegment = pathSegments[0];
// Don't rewrite URL for standalone pages like /citizens
const STANDALONE_PATHS = ['citizens'];
if (firstSegment && STANDALONE_PATHS.includes(firstSegment)) {
// Keep standalone path as-is
} else if (!firstSegment || !VALID_LANGS.includes(firstSegment as LanguageCode)) {
window.history.replaceState(null, '', `/${lang}${window.location.search}`);
}
}, [lang, isRTL]);
+3 -3
View File
@@ -1,5 +1,5 @@
{
"version": "1.0.197",
"buildTime": "2026-02-14T21:06:30.802Z",
"buildNumber": 1771103190812
"version": "1.0.198",
"buildTime": "2026-02-14T21:14:54.393Z",
"buildNumber": 1771103694399
}