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

mention-utils.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.mentionServices = void 0;
  4. exports.isMentionTextChar = isMentionTextChar;
  5. exports.isValidMention = isValidMention;
  6. var char_utils_1 = require("../char-utils");
  7. var mentionRegexes = {
  8. twitter: /^@\w{1,15}$/,
  9. instagram: /^@[_\w]{1,30}$/,
  10. soundcloud: /^@[-a-z0-9_]{3,25}$/,
  11. // TikTok usernames are 1-24 characters containing letters, numbers, underscores
  12. // and periods, but cannot end in a period: https://support.tiktok.com/en/getting-started/setting-up-your-profile/changing-your-username
  13. tiktok: /^@[.\w]{1,23}[\w]$/,
  14. // Youtube usernames are 3-30 characters containing letters, numbers, underscores,
  15. // dashes, or latin middle dots ('·').
  16. // https://support.google.com/youtube/answer/11585688?hl=en&co=GENIE.Platform%3DAndroid#tns
  17. youtube: /^@[-.·\w]{3,30}$/,
  18. };
  19. /**
  20. * Determines if the given character can be part of a mention's text characters.
  21. *
  22. * Accepts characters that match the RegExp `/[-\w.]/`, which are the possible
  23. * mention characters for any service.
  24. *
  25. * We'll confirm the match based on the user-configured service name after the
  26. * match is found.
  27. */
  28. function isMentionTextChar(charCode) {
  29. return (charCode === 45 /* Char.Dash */ || // '-'
  30. charCode === 46 /* Char.Dot */ || // '.'
  31. charCode === 95 /* Char.Underscore */ || // '_'
  32. (0, char_utils_1.isAsciiLetterChar)(charCode) ||
  33. (0, char_utils_1.isDigitChar)(charCode));
  34. }
  35. /**
  36. * Determines if the given `mention` text is valid.
  37. */
  38. function isValidMention(mention, serviceName) {
  39. var re = mentionRegexes[serviceName];
  40. return re.test(mention);
  41. }
  42. exports.mentionServices = [
  43. 'twitter',
  44. 'instagram',
  45. 'soundcloud',
  46. 'tiktok',
  47. 'youtube',
  48. ];
  49. //# sourceMappingURL=mention-utils.js.map