@n3okill/utils
Version:
Many javascript helpers
19 lines • 882 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEmailFormat = isEmailFormat;
/**
* Simple check if argument is in e-mail format
* @param {string} arg
* @param {boolean} matches
* @returns {boolean | string[] | null}
*
* ATTENTION: This function can cause a [Regular Expression Denial of Service (ReDoS)]:https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
*/
function isEmailFormat(arg, matches = false) {
return matches
? // eslint-disable-next-line security/detect-unsafe-regex
/^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,15}$/i.exec(arg)
: // eslint-disable-next-line security/detect-unsafe-regex
/^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,15}$/i.test(arg);
}
//# sourceMappingURL=isEmailFormat.js.map
;