File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ export function getTypeFromDocName(docName: string): string {
19
19
export function stripExtensionFromName ( docName : string ) : string {
20
20
let name = docName ;
21
21
// Check if the name includes a file extension, if the case remove it.
22
- if ( name . lastIndexOf ( "." ) == name . length - ( FILE_EXTENSION_LENGTH + 1 ) ) {
22
+ if ( name . length > FILE_EXTENSION_LENGTH &&
23
+ name . lastIndexOf ( "." ) == name . length - ( FILE_EXTENSION_LENGTH + 1 ) ) {
23
24
name = name . substring ( 0 , name . lastIndexOf ( "." ) ) ;
24
25
}
25
26
return name
Original file line number Diff line number Diff line change @@ -19,9 +19,14 @@ describe('compas-foundation', () => {
19
19
expect ( stripExtensionFromName ( name ) ) . to . be . equal ( name ) ;
20
20
} ) ;
21
21
22
- it ( 'when name is passed with extenions the same name is returned' , ( ) => {
22
+ it ( 'when name is passed with extenions the stripped name is returned' , ( ) => {
23
23
const name = 'just-some-station' ;
24
24
const extension = 'scd' ;
25
25
expect ( stripExtensionFromName ( name + '.' + extension ) ) . to . be . equal ( name ) ;
26
26
} ) ;
27
+
28
+ it ( 'when name is passed with length 3 the same name is returned' , ( ) => {
29
+ const name = 'sml' ;
30
+ expect ( stripExtensionFromName ( name ) ) . to . be . equal ( name ) ;
31
+ } ) ;
27
32
} ) ;
You can’t perform that action at this time.
0 commit comments