Fix normalization of email to lowercase

This commit is contained in:
Thomas Oberndörfer
2019-03-06 15:47:46 +01:00
parent aad782573d
commit 1fcf791560
5 changed files with 21 additions and 7 deletions

View File

@@ -78,6 +78,18 @@ exports.isEmail = function(data) {
return re.test(data);
};
/**
* Normalize email address to lowercase.
* @param {string} email The email address
* @return {string} lowercase email address
*/
exports.normalizeEmail = function(email) {
if (email) {
email = email.toLowerCase();
}
return email;
};
/**
* Create an error with a custom status attribute e.g. for http codes.
* @param {number} status The error's http status code