File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ function uriBase(req) {
4343}
4444
4545function basename ( fullpath ) {
46- var bname = ( fullpath . lastIndexOf ( '/' ) === fullpath . length - 1 ) ?'' :path . basename ( fullpath ) ;
46+ var bname = '' ;
47+ if ( fullpath ) {
48+ bname = ( fullpath . lastIndexOf ( '/' ) === fullpath . length - 1 ) ?'' :path . basename ( fullpath ) ;
49+ }
4750 return bname ;
4851}
4952
Original file line number Diff line number Diff line change @@ -5,14 +5,20 @@ var utils = require('../lib/utils');
55describe ( 'Utility functions' , function ( ) {
66
77 describe ( 'basename' , function ( ) {
8- it ( 'should return bar as relative path' , function ( ) {
8+ it ( 'should return bar as relative path for /foo/bar ' , function ( ) {
99 assert . equal ( utils . basename ( '/foo/bar' ) , 'bar' ) ;
1010 } ) ;
11- it ( 'should return empty as relative path' , function ( ) {
11+ it ( 'should return empty as relative path for /foo/ ' , function ( ) {
1212 assert . equal ( utils . basename ( '/foo/' ) , '' ) ;
1313 } ) ;
14- it ( 'should return empty as relative path' , function ( ) {
14+ it ( 'should return empty as relative path for / ' , function ( ) {
1515 assert . equal ( utils . basename ( '/' ) , '' ) ;
1616 } ) ;
17+ it ( 'should return empty as relative path for empty path' , function ( ) {
18+ assert . equal ( utils . basename ( '' ) , '' ) ;
19+ } ) ;
20+ it ( 'should return empty as relative path for undefined path' , function ( ) {
21+ assert . equal ( utils . basename ( undefined ) , '' ) ;
22+ } ) ;
1723 } ) ;
1824} ) ;
You can’t perform that action at this time.
0 commit comments