From 9492763d20f467cca7228928033dc2c91d38989b Mon Sep 17 00:00:00 2001 From: Amin Mahboubi Date: Mon, 12 Oct 2020 23:55:41 +0200 Subject: [PATCH] fix #569: add nofollow noreferrer noopener to links markdown --- src/utils.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index 0924a09e4..19d1fc0e8 100644 --- a/src/utils.js +++ b/src/utils.js @@ -146,6 +146,18 @@ export const truncate = (input, length, end = '...') => { return input; }; +const markDownRenderers = { + /** @param {{ href: string | undefined; children: React.ReactNode; }} props */ + link: (props) => { + if (!props.href || !props.href.startsWith('http')) return props.children; // could cause issue for app:// links? + return ( + + {props.children} + + ); + }, +}; + /** @type {(input: string | undefined, mentioned_users: import('stream-chat').UserResponse[] | undefined) => React.ReactNode} */ export const renderText = (text, mentioned_users) => { // take the @ mentions and turn them into markdown? @@ -182,8 +194,8 @@ export const renderText = (text, mentioned_users) => {