function replaceBasename ( pathname , basename ? ) { if ( typeof basename !== 'string' ) { return pathname ; } if ( basename [ 0 ] !== '/' ) { basename = `/${ basename }` ; } if ( pathname . startsWith ( basename ) ) { pathname = pathname . substring ( basename . length ) ; if ( ! pathname . startsWith ( '/' ) ) { pathname = `/${ pathname || '' }` ; } } return pathname ; } export default replaceBasename ;