import { posix , sep } from 'path' ; param url export const isAbsoluteUrl = ( url ) : boolean => { return ( /^(https?:)?\/\/.+/ ) . test ( url ) ; } ; param str export const addTrailingSlash = ( str ) : string => { return str . substr ( - 1 ) === '/' ? str : `${ str }/` ; } ; param pathStr returns export const formatPath = ( pathStr ) : string => { return process . platform === 'win32' ? pathStr . split ( sep ) . join ( '/' ) : pathStr ; } ; export const getEntryUrl = ( entries ) => { if ( typeof entries === 'string' ) { return entries ; } const theFirstKeyGotten = Object . keys ( entries ) [ 0 ] ; return entries [ theFirstKeyGotten ] ; } ; param entries returns export const isSingleEntry = ( entries ) => { if ( typeof entries === 'object' && Object . keys ( entries ) . length > 1 ) { return false ; } return true ; } ; export function getRelativePath ( rootDir , path ) { const formatedRootDir = formatPath ( rootDir ) ; let relativePath = formatPath ( path ) ; if ( relativePath . includes ( formatedRootDir ) ) { relativePath = `/${ posix . relative ( formatedRootDir , relativePath ) }` ; } return relativePath ; }