Skip to content

Commit

Permalink
fix: handle nordic characters when converting to pascal-case (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhels authored Jan 15, 2024
1 parent 848bbe3 commit 7e563eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/core/src/utils/case.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ describe('pascal case testing', () => {
expect(pascal('')).toBe('');
expect(pascal(undefined)).toBe('');
});

it('should handle nordic characters', () => {
// norwegian
expect(pascal('ærlig-ønske-åpen')).toBe('ÆrligØnskeÅpen');
expect(pascal('ÆRLIG_ØNSKE_ÅPEN')).toBe('ÆrligØnskeÅpen');
// swedish
expect(pascal('ärlig-önske-öppen')).toBe('ÄrligÖnskeÖppen');
expect(pascal('ÄRLIG_ÖNSKE_ÖPPEN')).toBe('ÄrligÖnskeÖppen');
// danish
expect(pascal('ærlig-ønske-åben')).toBe('ÆrligØnskeÅben');
expect(pascal('ÆRLIG_ØNSKE_ÅBEN')).toBe('ÆrligØnskeÅben');
});
});

describe('camel case testing', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const pascal = (s: string) => {
s = low.call(s);
}

const pascalString = (s?.match(/[a-zA-Z0-9]+/g) || [])
const pascalString = (s?.match(/[a-zA-Z0-9\u00C0-\u017F]+/g) || [])
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
.join('');

Expand Down

0 comments on commit 7e563eb

Please sign in to comment.