mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-10-03 18:23:47 +10:00
fix(schema): case the present label by its language only
page.locale accepts any string. A malformed tag such as "de-DE-" made toLocaleUpperCase throw a RangeError, so parseResumeData failed and the resume could not load. The language code always comes from the parser's word list, so it is a valid tag.
This commit is contained in:
@@ -96,6 +96,10 @@ describe("getPresentLabel", () => {
|
||||
expect(getPresentLabel("de-DE")).toBe("Heute");
|
||||
expect(getPresentLabel("xx-XX")).toBe("Present");
|
||||
});
|
||||
|
||||
it("reads a malformed locale tag by its language instead of throwing", () => {
|
||||
expect(getPresentLabel("de-DE-")).toBe("Heute");
|
||||
});
|
||||
});
|
||||
|
||||
describe("upgradeResumeDates", () => {
|
||||
|
||||
@@ -55,7 +55,8 @@ export function getPresentLabel(locale: string): string {
|
||||
|
||||
const word = ONGOING_TOKENS_BY_LANGUAGE[language]?.[0];
|
||||
if (!word) return "Present";
|
||||
return word.charAt(0).toLocaleUpperCase(locale) + word.slice(1);
|
||||
// Case the word by its language alone: `locale` can be a malformed tag ("de-DE-") that throws a RangeError.
|
||||
return word.charAt(0).toLocaleUpperCase(language) + word.slice(1);
|
||||
}
|
||||
|
||||
const toEndpoint = (value: YearMonth): PeriodEndpoint => {
|
||||
|
||||
Reference in New Issue
Block a user