import Types from './types' ; /**
 * Helper to build a new URL from different params
 */ export function toURL ( origin , baseURL , endpoint , queryString ? ) { const removeLeadingSlash = ( text ) => { return text . replace ( /^\// , '' ) ; } ; const removeTrailingSlash = ( text ) => { return text . replace ( /\/$/ , '' ) ; } ; const urlParts = [ ] ; urlParts . push ( removeTrailingSlash ( origin ) ) ; urlParts . push ( removeLeadingSlash ( removeTrailingSlash ( baseURL ) ) ) ; urlParts . push ( removeLeadingSlash ( endpoint ) ) ; const url = new URL ( urlParts . join ( '/' ) ) ; if ( queryString ) { Object . keys ( queryString ) . forEach ( key => url . searchParams . append ( key , String ( queryString [ key ] ) ) ) ; } return url ; } param obj { object } export function cleanHeaders ( obj ) { return Object . keys ( obj ) . reduce ( ( acc , key ) => { if ( obj [ key ] !== undefined ) { acc [ key ] = obj [ key ] ; } return acc ; } , { } as Record < string , any > ) ; }