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
23104
pnpm-lock.yaml
23104
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
16
src/app.ts
16
src/app.ts
|
|
@ -7,11 +7,17 @@ export function rootContainer(container: any) {
|
|||
'en': require('./locales/en-US.json'),
|
||||
'zh': require('./locales/zh-CN.json'),
|
||||
};
|
||||
let currentLocale = intl.determineLocale({
|
||||
urlLocaleKey: 'lang',
|
||||
cookieLocaleKey: 'lang',
|
||||
localStorageLocaleKey: 'lang',
|
||||
}).slice(0, 2);
|
||||
let currentLocale: string;
|
||||
try {
|
||||
currentLocale = intl.determineLocale({
|
||||
urlLocaleKey: 'lang',
|
||||
cookieLocaleKey: 'lang',
|
||||
localStorageLocaleKey: 'lang',
|
||||
}).slice(0, 2);
|
||||
} catch (e) {
|
||||
// Handle decodeURIComponent errors from malformed cookies
|
||||
currentLocale = '';
|
||||
}
|
||||
|
||||
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
||||
currentLocale = 'zh';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user