File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -340,11 +340,12 @@ win32.basename = function(path, ext) {
340340 if ( ext !== undefined && typeof ext !== 'string' )
341341 throw new TypeError ( '"ext" argument must be a string' ) ;
342342
343- var f = win32SplitPath ( path ) [ 2 ] ;
344- // TODO: make this comparison case-insensitive on windows?
345- if ( ext && f . substr ( - 1 * ext . length ) === ext ) {
343+ let f = win32SplitPath ( path ) [ 2 ] ;
344+
345+ if ( ext && f . toLowerCase ( ) . endsWith ( ext . toLowerCase ( ) ) ) {
346346 f = f . substr ( 0 , f . length - ext . length ) ;
347347 }
348+
348349 return f ;
349350} ;
350351
Original file line number Diff line number Diff line change @@ -406,6 +406,13 @@ assert.equal(path.win32.delimiter, ';');
406406// posix
407407assert . equal ( path . posix . delimiter , ':' ) ;
408408
409+ // ensure ext comparison is case-insensitive on windows
410+ const upBaseName = path . win32 . basename ( 'same.txt' , '.TXT' ) ;
411+ const loBaseName = path . win32 . basename ( 'SAME.TXT' , '.txt' ) ;
412+
413+ assert . strictEqual ( upBaseName . length ,
414+ loBaseName . length ,
415+ 'both should return "same"' ) ;
409416
410417if ( common . isWindows )
411418 assert . deepEqual ( path , path . win32 , 'should be win32 path module' ) ;
You can’t perform that action at this time.
0 commit comments