Files
planka/server/utils/mentions.js
2025-08-11 13:52:17 +02:00

21 lines
576 B
JavaScript

/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const MENTION_ID_REGEX = /@\[.*?\]\((.*?)\)/g;
const MENTION_USERNAME_REGEX = /@\[(.*?)\]\(.*?\)/g;
const extractMentionIds = (text) => {
const matches = [...text.matchAll(MENTION_ID_REGEX)];
return matches.map((match) => match[1]);
};
const mentionMarkupToText = (markup) =>
markup.replace(MENTION_USERNAME_REGEX, (_, username) => `@${username}`);
module.exports = {
extractMentionIds,
mentionMarkupToText,
};