Skip to content

Commit

Permalink
Merge branch 'master' into mediainfo-use-relative-path
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored Sep 29, 2023
2 parents aca269f + 7117764 commit 1ec8456
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions client/src/javascript/components/general/LinkedText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
Expand Down

0 comments on commit 1ec8456

Please sign in to comment.