7 lines
230 B
TypeScript
7 lines
230 B
TypeScript
|
// Support <http://link|Text>
|
||
|
export const formatText = (text: string): string =>
|
||
|
text.replace(
|
||
|
new RegExp('(?:<|<)((?:https|http):\\/\\/[^\\|]+)\\|(.+?)(?=>|>)(?:>|>)', 'gm'),
|
||
|
(match, url, title) => `[${title}](${url})`
|
||
|
);
|