mirror of
https://github.com/plankanban/planka.git
synced 2025-12-27 09:14:59 +03:00
ref: Little refactoring
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
const MENTIONS_REGEX = /@\[(.*?)\]\(.*?\)/g;
|
||||
|
||||
const formatTextWithMentions = (text) => text.replace(MENTIONS_REGEX, '@$1');
|
||||
|
||||
module.exports = {
|
||||
formatTextWithMentions,
|
||||
};
|
||||
22
server/utils/mentions.js
Normal file
22
server/utils/mentions.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/*!
|
||||
* 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_NAME_REGEX = /@\[(.*?)\]\(.*?\)/g;
|
||||
|
||||
const extractMentionIds = (text) => {
|
||||
const matches = [...text.matchAll(MENTION_ID_REGEX)];
|
||||
return matches.map((match) => match[1]);
|
||||
};
|
||||
|
||||
const formatTextWithMentions = (text) => text.replace(MENTION_NAME_REGEX, '@$1');
|
||||
|
||||
module.exports = {
|
||||
MENTION_ID_REGEX,
|
||||
MENTION_NAME_REGEX,
|
||||
|
||||
extractMentionIds,
|
||||
formatTextWithMentions,
|
||||
};
|
||||
Reference in New Issue
Block a user