const PATH_SEPARATOR = '/' ; param paths param trailing export default function joinUrl ( paths , trailing = false ) { const normalizedPaths = paths . map ( ( path ) => { let normalizedPath = path ; while ( normalizedPath [ 0 ] === PATH_SEPARATOR ) { normalizedPath = normalizedPath . slice ( 1 ) ; } while ( normalizedPath [ normalizedPath . length - 1 ] === PATH_SEPARATOR ) { normalizedPath = normalizedPath . slice ( 0 , - 1 ) ; } return normalizedPath ; } ) ; return `${ normalizedPaths . join ( PATH_SEPARATOR ) }${ trailing ? PATH_SEPARATOR : '' }` ; }