From a3d502ed5ecc99b8db3f51cac89b73cfa559bd03 Mon Sep 17 00:00:00 2001 From: Viktor Honti Date: Mon, 26 Sep 2022 14:08:11 +0200 Subject: [PATCH] Support spaces when pascal casing file names --- packages/core/src/state.test.ts | 5 +++++ packages/core/src/state.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/state.test.ts b/packages/core/src/state.test.ts index 26a304c3..e2183d9f 100644 --- a/packages/core/src/state.test.ts +++ b/packages/core/src/state.test.ts @@ -24,6 +24,11 @@ describe('state', () => { filePath: 'a&b~c-d_e.svg', componentName: 'SvgAbcDE', }) + expect(expandState({ filePath: 'Arrow up.svg' })).toEqual({ + filePath: 'Arrow up.svg', + componentName: 'SvgArrowUp', + }) + }) }) }) diff --git a/packages/core/src/state.ts b/packages/core/src/state.ts index 20e4f099..c9900d57 100644 --- a/packages/core/src/state.ts +++ b/packages/core/src/state.ts @@ -13,7 +13,7 @@ export interface State { } } -const VALID_CHAR_REGEX = /[^a-zA-Z0-9_-]/g +const VALID_CHAR_REGEX = /[^a-zA-Z0-9 _-]/g const getComponentName = (filePath?: string): string => { if (!filePath) return 'SvgComponent'