From 6ee639a039a0001d3b97fef024f2bd0c3e107182 Mon Sep 17 00:00:00 2001 From: Viktor Honti <142130+jamonserrano@users.noreply.github.com> Date: Wed, 28 Sep 2022 08:51:55 +0200 Subject: [PATCH] feat: support spaces in file names (#779) Co-authored-by: Viktor Honti --- 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'