From 221ae5b82124c8a729ccb83b398908cf7afc46ff Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 22 Oct 2020 18:09:17 -0400 Subject: [PATCH] fix inline player not showing up broken from previous commit --- ui/component/markdownLink/view.jsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ui/component/markdownLink/view.jsx b/ui/component/markdownLink/view.jsx index e2cefa0e7..5b4d205f6 100644 --- a/ui/component/markdownLink/view.jsx +++ b/ui/component/markdownLink/view.jsx @@ -40,14 +40,15 @@ function MarkdownLink(props: Props) { const protocolRegex = new RegExp('^(https?|lbry|mailto)+:', 'i'); const protocol = href ? protocolRegex.exec(href) : null; - // 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 (!simpleLinks && protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) { - const linkUrlObject = new URL(decodedUri); + let linkUrlObject; + try { + linkUrlObject = new URL(decodedUri); + } catch (e) {} + + let lbryUrlFromLink; + if (linkUrlObject) { const linkDomain = linkUrlObject.host; const isKnownAppDomainLink = KNOWN_APP_DOMAINS.includes(linkDomain); - let lbryUrlFromLink; if (isKnownAppDomainLink) { const linkPathname = decodeURIComponent( linkUrlObject.pathname.startsWith('//') ? linkUrlObject.pathname.slice(2) : linkUrlObject.pathname.slice(1) @@ -58,7 +59,12 @@ function MarkdownLink(props: Props) { lbryUrlFromLink = possibleLbryUrl; } } + } + // 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)) || lbryUrlFromLink) { element = (