From 711776484dc0ab44ad01c4caaec8f39d78d8257f Mon Sep 17 00:00:00 2001 From: Trim21 Date: Fri, 29 Sep 2023 11:40:06 +0800 Subject: [PATCH] LinkedText: fix torrent comment line break (#667) --- .../components/general/LinkedText.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/client/src/javascript/components/general/LinkedText.tsx b/client/src/javascript/components/general/LinkedText.tsx index a49ccdb3..b0f4b145 100644 --- a/client/src/javascript/components/general/LinkedText.tsx +++ b/client/src/javascript/components/general/LinkedText.tsx @@ -18,15 +18,19 @@ function isValidHttpUrl(s: string) { } const LinkedText: FC = ({text, className}: LinkedTextProps) => { - const nodes = text.split(/\s/).map((s) => - isValidHttpUrl(s.trimEnd()) ? ( - - {s} - - ) : ( - s - ), - ); + const nodes = text.split(/([ \n])/).map((s) => { + if (s === '\n') { + return
; + } + if (isValidHttpUrl(s)) { + return ( + + {s} + + ); + } + return s; + }); return {nodes}; };