mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-13 11:06:07 +08:00
Fix URIError from malformed cookies causing white screen on load (#2811)
* Initial plan * Fix decodeURIComponent error in cookie parsing by adding try-catch Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Add type annotation and logging to catch block per code review Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Fix TypeScript errors in deps.ts - remove unused path parameter Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Revert pnpm-lock.yaml to avoid unnecessary lockfile version upgrade Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
parent
06aa07329f
commit
1f2fd8ac02
|
|
@ -58,6 +58,6 @@ export default async (src: string = 'deps') => {
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher
|
watcher
|
||||||
.on('add', (path) => linkToNodeModule(src))
|
.on('add', () => linkToNodeModule(src))
|
||||||
.on('change', (path) => linkToNodeModule(src));
|
.on('change', () => linkToNodeModule(src));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
17
src/app.ts
17
src/app.ts
|
|
@ -7,11 +7,18 @@ 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;
|
||||||
urlLocaleKey: 'lang',
|
try {
|
||||||
cookieLocaleKey: 'lang',
|
currentLocale = intl.determineLocale({
|
||||||
localStorageLocaleKey: 'lang',
|
urlLocaleKey: 'lang',
|
||||||
}).slice(0, 2);
|
cookieLocaleKey: 'lang',
|
||||||
|
localStorageLocaleKey: 'lang',
|
||||||
|
}).slice(0, 2);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
// Handle decodeURIComponent errors from malformed cookies
|
||||||
|
console.warn('Failed to determine locale from cookies:', e);
|
||||||
|
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