diff --git a/src/parser/extract-id.test.js b/src/parser/extract-id.test.js index c318e25..0bcaf38 100644 --- a/src/parser/extract-id.test.js +++ b/src/parser/extract-id.test.js @@ -2,6 +2,6 @@ import { extractId } from './extract-id'; describe('extract-id', () => { test('name with spaces', () => { - expect(extractId({ name: 'Name with spaces' })).toBe('Name_with_spaces'); + expect(extractId({ name: 'Name with spaces' })).toBe('NameWithSpaces'); }); }); diff --git a/src/parser/extract-id.ts b/src/parser/extract-id.ts index e47f87a..2e214e2 100644 --- a/src/parser/extract-id.ts +++ b/src/parser/extract-id.ts @@ -4,5 +4,5 @@ export function extractId({ id, name }: { id?: string; name?: string }): string return id; } - return name.replaceAll(/[^a-zA-Z0-9_]/g, '_'); + return name.replace(/\W+(.)/g, (_, chr) => chr.toUpperCase()); }