智慧水务管理系统 - 精河县供水工程综合管理平台

email-utils.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isEmailLocalPartStartChar = exports.mailtoSchemePrefixRe = void 0;
  4. exports.isEmailLocalPartChar = isEmailLocalPartChar;
  5. exports.isValidEmail = isValidEmail;
  6. var char_utils_1 = require("../char-utils");
  7. var uri_utils_1 = require("./uri-utils");
  8. /**
  9. * A regular expression to match a 'mailto:' prefix on an email address.
  10. */
  11. exports.mailtoSchemePrefixRe = /^mailto:/i;
  12. /**
  13. * Determines if the given character may start the "local part" of an email
  14. * address. The local part is the part to the left of the '@' sign.
  15. *
  16. * Technically according to the email spec, any of the characters in the
  17. * {@link emailLocalPartCharRegex} can start an email address (including any of
  18. * the special characters), but this is so rare in the wild and the
  19. * implementation is much simpler by only starting an email address with a word
  20. * character. This is especially important when matching the '{' character which
  21. * generally starts a brace that isn't part of the email address.
  22. */
  23. exports.isEmailLocalPartStartChar = char_utils_1.isAlphaNumericOrMarkChar; // alias for clarity
  24. /**
  25. * Determines if the given character can be part of the "local part" of an email
  26. * address. The local part is the part to the left of the '@' sign.
  27. *
  28. * Checking for an email address's start char is handled with {@link #isEmailLocalPartStartChar}
  29. */
  30. function isEmailLocalPartChar(charCode) {
  31. return (0, exports.isEmailLocalPartStartChar)(charCode) || (0, char_utils_1.isValidEmailLocalPartSpecialChar)(charCode);
  32. }
  33. /**
  34. * Determines if the given email address is valid. We consider it valid if it
  35. * has a valid TLD in its host.
  36. *
  37. * @param emailAddress email address
  38. * @return true is email have valid TLD, false otherwise
  39. */
  40. function isValidEmail(emailAddress) {
  41. var emailAddressTld = emailAddress.split('.').pop(); // as long as we have a valid string (as opposed to null or undefined), we will always get at least one element in the .split('.') array
  42. return (0, uri_utils_1.isKnownTld)(emailAddressTld);
  43. }
  44. //# sourceMappingURL=email-utils.js.map