/**
 * Utility to remove trailing, leading or duplicate slashes.
 * By default will only remove duplicates.
 */ export const removeSlashes = ( url , { trailing = false , leading = false , duplicates = true , } = { } ) : string => { if ( duplicates ) { url = url . replace ( /\/{2,}/g , '/' ) ; } if ( trailing ) { url = url . replace ( /\/$/ , '' ) ; } if ( leading ) { url = url . replace ( /^\// , '' ) ; } return url ; } ;