mirror of
https://github.com/zoriya/flood.git
synced 2026-06-01 18:47:44 +00:00
LinkedText: fix torrent comment line break (#667)
This commit is contained in:
@@ -18,15 +18,19 @@ function isValidHttpUrl(s: string) {
|
||||
}
|
||||
|
||||
const LinkedText: FC<LinkedTextProps> = ({text, className}: LinkedTextProps) => {
|
||||
const nodes = text.split(/\s/).map((s) =>
|
||||
isValidHttpUrl(s.trimEnd()) ? (
|
||||
<a href={s.trimEnd()} target="_blank" rel="noopener noreferrer">
|
||||
{s}
|
||||
</a>
|
||||
) : (
|
||||
s
|
||||
),
|
||||
);
|
||||
const nodes = text.split(/([ \n])/).map((s) => {
|
||||
if (s === '\n') {
|
||||
return <br />;
|
||||
}
|
||||
if (isValidHttpUrl(s)) {
|
||||
return (
|
||||
<a href={s.trimEnd()} target="_blank" rel="noopener noreferrer">
|
||||
{s}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
return s;
|
||||
});
|
||||
|
||||
return <span className={className}>{nodes}</span>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user