File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -60,17 +60,25 @@ function get_name(filename: string) {
60
60
// eslint-disable-next-line no-useless-escape
61
61
const parts = filename . split ( / [ \/ \\ ] / ) ;
62
62
63
- if ( parts . length > 1 && / ^ i n d e x \. \w + / . test ( parts [ parts . length - 1 ] ) ) {
64
- parts . pop ( ) ;
63
+ if ( parts . length > 1 ) {
64
+ const index_match = parts [ parts . length - 1 ] . match ( / ^ i n d e x ( \. \w + ) / ) ;
65
+ if ( index_match ) {
66
+ parts . pop ( ) ;
67
+ parts [ parts . length - 1 ] += index_match [ 1 ] ;
68
+ }
65
69
}
66
70
67
71
const base = parts . pop ( )
68
- . replace ( / \. . + / , "" )
72
+ . replace ( / \. [ ^ . ] + $ / , "" )
69
73
. replace ( / [ ^ a - z A - Z _ $ 0 - 9 ] + / g, '_' )
70
74
. replace ( / ^ _ / , '' )
71
75
. replace ( / _ $ / , '' )
72
76
. replace ( / ^ ( \d ) / , '_$1' ) ;
73
77
78
+ if ( ! base ) {
79
+ throw new Error ( `Could not derive component name from file ${ filename } ` ) ;
80
+ }
81
+
74
82
return base [ 0 ] . toUpperCase ( ) + base . slice ( 1 ) ;
75
83
}
76
84
You can’t perform that action at this time.
0 commit comments