mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-08 15:06:08 +08:00
Fix decodeURIComponent error in cookie parsing by adding try-catch
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
parent
d6775108ea
commit
73822d6361
22512
pnpm-lock.yaml
22512
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -7,11 +7,17 @@ export function rootContainer(container: any) {
|
||||||
'en': require('./locales/en-US.json'),
|
'en': require('./locales/en-US.json'),
|
||||||
'zh': require('./locales/zh-CN.json'),
|
'zh': require('./locales/zh-CN.json'),
|
||||||
};
|
};
|
||||||
let currentLocale = intl.determineLocale({
|
let currentLocale: string;
|
||||||
|
try {
|
||||||
|
currentLocale = intl.determineLocale({
|
||||||
urlLocaleKey: 'lang',
|
urlLocaleKey: 'lang',
|
||||||
cookieLocaleKey: 'lang',
|
cookieLocaleKey: 'lang',
|
||||||
localStorageLocaleKey: 'lang',
|
localStorageLocaleKey: 'lang',
|
||||||
}).slice(0, 2);
|
}).slice(0, 2);
|
||||||
|
} catch (e) {
|
||||||
|
// Handle decodeURIComponent errors from malformed cookies
|
||||||
|
currentLocale = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
||||||
currentLocale = 'zh';
|
currentLocale = 'zh';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user