Skip to content

Commit

Permalink
Improve generated stories ID
Browse files Browse the repository at this point in the history
  • Loading branch information
j3rem1e committed Mar 1, 2021
1 parent 9b4875e commit 0d67b0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser/extract-id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
2 changes: 1 addition & 1 deletion src/parser/extract-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit 0d67b0c

Please sign in to comment.