From 39615392db5c30ff34c0d5b097a70ea89d95bb4f Mon Sep 17 00:00:00 2001 From: Tienifr Date: Thu, 13 Jul 2023 00:24:25 +0700 Subject: [PATCH] modify comment --- lib/str.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/str.js b/lib/str.js index 383dcf90..6c099f4e 100644 --- a/lib/str.js +++ b/lib/str.js @@ -943,11 +943,13 @@ const Str = { * @returns {bool} */ isValidMention(mention) { - // A valid mention starts with a space or @, or - // starts and ends with a *, _, #, ', or " (with no preceding characters). + // Mentions can start @ proceeded by a space, eg "ping @user@domain.tld" if (/[\s@]/g.test(mention.charAt(0))) { return true; } + + // Mentions can also start and end with a *, _, ~, ', or " (with no other preceding characters) + // eg "ping *@user@domain.tld*" const firstChar = mention.charAt(0); const lastChar = mention.charAt(mention.length - 1); return /[*~_'"]/g.test(firstChar) && /[*~_'"]/g.test(lastChar) && firstChar === lastChar;