From 52e5d4a0118fbaae921ac82a74f73b12a43731d5 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Thu, 25 Feb 2021 14:30:50 -0500 Subject: [PATCH] links: enforce valid URI on render Fixes urbit/landscape#280 --- pkg/interface/src/views/apps/links/components/LinkItem.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/apps/links/components/LinkItem.tsx b/pkg/interface/src/views/apps/links/components/LinkItem.tsx index 8934416b6..027b25926 100644 --- a/pkg/interface/src/views/apps/links/components/LinkItem.tsx +++ b/pkg/interface/src/views/apps/links/components/LinkItem.tsx @@ -67,6 +67,7 @@ export const LinkItem = (props: LinkItemProps): ReactElement => { const size = node.children ? node.children.size : 0; const contents = node.post.contents; const hostname = URLparser.exec(contents[1].url) ? URLparser.exec(contents[1].url)[4] : null; + const href = URLparser.exec(contents[1].url) ? contents[1].url : `http://${contents[1].url}` const baseUrl = props.baseUrl || `/~404/${resource}`; @@ -120,7 +121,7 @@ export const LinkItem = (props: LinkItemProps): ReactElement => { { remoteRef.current = r }} renderUrl={false} - url={contents[1].url} + url={href} text={contents[0].text} unfold={true} onLoad={onMeasure} @@ -145,7 +146,7 @@ export const LinkItem = (props: LinkItemProps): ReactElement => { }} /> - + {hostname}