fixes #3383 by formatting lbry links differently

This commit is contained in:
Dalton 2020-01-03 20:35:06 -06:00 committed by Sean Yesmunt
parent b2948674bc
commit bd4de2fc4e

View file

@ -8,6 +8,8 @@ import reactRenderer from 'remark-react';
import ExternalLink from 'component/externalLink';
import defaultSchema from 'hast-util-sanitize/lib/github.json';
import { formatedLinks, inlineLinks } from 'util/remark-lbry';
import { Link } from 'react-router-dom';
import { formatLbryUrlForWeb } from 'util/url';
type SimpleTextProps = {
children?: React.Node,
@ -30,7 +32,24 @@ const SimpleText = (props: SimpleTextProps) => {
};
const SimpleLink = (props: SimpleLinkProps) => {
const { href, title, children } = props;
const { title, children } = props;
let { href } = props;
if (href && href.startsWith('lbry://')) {
href = formatLbryUrlForWeb(href);
// using NavLink after format to handle "/" vs "#/"
// for web and desktop scenarios respectively
return (
<Link
title={title}
to={href}
onClick={e => {
e.stopPropagation();
}}
>
{children}
</Link>
);
}
return (
<a href={href} title={title}>
{children}