import { isIPv4 } from "net" ; import { domainToASCII } from "url" ; param { string } email return { string } export default ( email ) : string => { const localEnd = email . indexOf ( "@" ) ; if ( localEnd === - 1 ) return "" ; const local = email . slice ( 0 , localEnd ) . toLowerCase ( ) ; if ( local === "" ) return "" ; const host = domainToASCII ( email . slice ( localEnd + 1 ) ) ; if ( host === "" || host [ 0 ] === "[" || isIPv4 ( host ) ) return "" ; return `${ local }@${ host }` ; } ;