param { string } url return { ? string } export function getOriginFromUrl ( url ) { const re = new RegExp ( '^(https?://)[^/]+/?' ) ; const originarray = re . exec ( url ) ; if ( originarray == null ) { return null ; } let origin = originarray [ 0 ] ; while ( origin . charAt ( origin . length - 1 ) === '/' ) { origin = origin . substring ( 0 , origin . length - 1 ) ; } return origin ; } export function getDomainFromOrigin ( origin ) { return origin . replace ( new RegExp ( '^https?://' ) , '' ) . replace ( new RegExp ( ':[0-9]+$' ) , '' ) ; }