Skip to content

Commit

Permalink
modify comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Jul 12, 2023
1 parent 832b1d8 commit 3961539
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/str.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3961539

Please sign in to comment.