Files
planka/server/utils/mentions.js

21 lines
576 B
JavaScript
Raw Normal View History

2025-06-06 12:34:09 +02:00
/*!
* 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;
2025-08-11 13:52:17 +02:00
const MENTION_USERNAME_REGEX = /@\[(.*?)\]\(.*?\)/g;
2025-06-06 12:34:09 +02:00
const extractMentionIds = (text) => {
const matches = [...text.matchAll(MENTION_ID_REGEX)];
return matches.map((match) => match[1]);
};
2025-08-11 13:52:17 +02:00
const mentionMarkupToText = (markup) =>
markup.replace(MENTION_USERNAME_REGEX, (_, username) => `@${username}`);
2025-06-06 12:34:09 +02:00
module.exports = {
extractMentionIds,
2025-08-11 13:52:17 +02:00
mentionMarkupToText,
2025-06-06 12:34:09 +02:00
};