diff --git a/src/utils.ts b/src/utils.ts index 2629753..078973d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,8 +3,8 @@ import {upperFirst} from 'lodash'; import {pipe} from 'lodash/fp'; export const moduleName = (name: string): string => { - const removeSpace = (input: string): string => input.replace(' ', ''); - const replaceDash = (input: string): string => input.replace('-', '__'); + const removeSpace = (input: string): string => input.replace(/\s/g, ''); + const replaceDash = (input: string): string => input.replace(/-/g, '__'); const addPrefix = (input: string): string => input.startsWith('Type') ? input : `Type${input}`; return pipe([replaceDash, upperFirst, addPrefix, removeSpace])(name); }; diff --git a/test/utils.test.ts b/test/utils.test.ts index 1cc2452..d5a8359 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -8,6 +8,7 @@ describe('a moduleName function', () => { {input: 'hello-World', expect: 'TypeHello__World'}, {input: '0helloWorld', expect: 'Type0helloWorld'}, {input: '0-helloWorld', expect: 'Type0__helloWorld'}, + {input: '1-0-helloWorld', expect: 'Type1__0__helloWorld'}, {input: 'hello World', expect: 'TypeHelloWorld'}, {input: 'hello-World', expect: 'TypeHello__World'}, {input: '12345', expect: 'Type12345'},