File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 11import path from 'path'
22import camelcase from 'camelcase'
33
4+ const validCharacters = / [ ^ a - z A - Z 0 - 9 _ - ] / g
5+
46function getComponentName ( state ) {
57 if ( ! state . filePath ) return 'SvgComponent'
6- const pascalCaseFileName = camelcase ( path . parse ( state . filePath ) . name , {
7- pascalCase : true ,
8- } )
8+ const pascalCaseFileName = camelcase (
9+ path . parse ( state . filePath ) . name . replace ( validCharacters , '' ) ,
10+ {
11+ pascalCase : true ,
12+ } ,
13+ )
914 return `Svg${ pascalCaseFileName } `
1015}
1116
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ describe('state', () => {
2020 filePath : '1_big_svg.svg' ,
2121 componentName : 'Svg1BigSvg' ,
2222 } )
23+ expect ( expandState ( { filePath : 'a&b~c-d_e.svg' } ) ) . toEqual ( {
24+ filePath : 'a&b~c-d_e.svg' ,
25+ componentName : 'SvgAbcDE' ,
26+ } )
2327 } )
2428 } )
2529} )
You can’t perform that action at this time.
0 commit comments