File tree Expand file tree Collapse file tree
projects/packages/search/src/instant-search/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,7 +150,11 @@ export default function AnswersPanel( {
150150 < ul className = "jp-search-answers-panel__citations" >
151151 { citations . map ( ( { title, url } , i ) => (
152152 < li key = { i } >
153- < a href = { url } target = "_blank" rel = "noopener noreferrer" >
153+ < a
154+ href = { / ^ h t t p s ? : \/ \/ / i. test ( url ) ? url : '#' }
155+ target = "_blank"
156+ rel = "noopener noreferrer"
157+ >
154158 { title }
155159 < ExternalLinkIcon />
156160 </ a >
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const Sidebar = props => {
1313 { props . citations . map ( ( citation , i ) => (
1414 < a
1515 key = { i }
16- href = { citation . url }
16+ href = { / ^ h t t p s ? : \/ \/ / i . test ( citation . url ) ? citation . url : '#' }
1717 className = "jetpack-instant-search__sidebar-citation-card"
1818 target = "_blank"
1919 rel = "noopener noreferrer"
@@ -22,7 +22,13 @@ const Sidebar = props => {
2222 { citation . title }
2323 </ span >
2424 < span className = "jetpack-instant-search__sidebar-citation-url" >
25- { new URL ( citation . url ) . hostname }
25+ { ( ( ) => {
26+ try {
27+ return new URL ( citation . url ) . hostname ;
28+ } catch {
29+ return '' ;
30+ }
31+ } ) ( ) }
2632 </ span >
2733 </ a >
2834 ) ) }
You can’t perform that action at this time.
0 commit comments