import { get as getMainDomain } from "psl" ; const getHostname = ( url ) => { const matches = url . match ( /^(?:https?:)?(?:\/\/)?([^\/\?]+)/i ) ; return matches ? matches [ 1 ] : url ; } ; export const extractDomain = ( url ) => getMainDomain ( getHostname ( url ) ) || "" ;