fix app crash

This commit is contained in:
Sean Yesmunt 2020-10-22 14:06:28 -04:00
parent 851b2d13e4
commit ad88d8993d

View file

@ -24,13 +24,16 @@ function MarkdownLink(props: Props) {
return children || null;
}
let element = <span>{children}</span>;
// Regex for url protocol
const protocolRegex = new RegExp('^(https?|lbry|mailto)+:', 'i');
const protocol = href ? protocolRegex.exec(href) : null;
// Return plain text if no valid url
let element = <span>{children}</span>;
// Return external link if protocol is http or https
// Return plain text if no valid url
// Return external link if protocol is http or https
// Return local link if protocol is lbry uri
if (protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) {
const linkUrlObject = new URL(decodedUri);
const linkDomain = linkUrlObject.host;
const isKnownAppDomainLink = KNOWN_APP_DOMAINS.includes(linkDomain);
@ -46,8 +49,6 @@ function MarkdownLink(props: Props) {
}
}
// Return local link if protocol is lbry uri
if ((protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) || lbryUrlFromLink) {
element = (
<ClaimLink
uri={lbryUrlFromLink || decodedUri}