export const isSubDomain = ( hostname , domain ) => { if ( hostname === domain ) { return true ; } return hostname . endsWith ( `.${ domain }` ) ; } ; export const getHostname = ( url ) => { if ( /^https?:\/\// . test ( url ) ) { const parser = document . createElement ( 'a' ) ; parser . href = url ; return parser . hostname ; } return window . location . hostname ; } ; export const isExternal = ( url ) => { try { return window . location . hostname !== getHostname ( url ) ; } catch ( e ) { return true ; } } ;