@@ -24,6 +24,7 @@ import styles from './KeyValue.css';
2424import Button from 'react-devtools-shared/src/devtools/views/Button' ;
2525import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon' ;
2626import { InspectedElementContext } from './InspectedElementContext' ;
27+ import { PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE } from './constants' ;
2728
2829import type { InspectedElement } from './types' ;
2930import type { Element } from 'react-devtools-shared/src/devtools/views/Components/types' ;
@@ -243,11 +244,14 @@ export default function KeyValue({
243244 displayValue = 'undefined' ;
244245 }
245246
246- let shouldDisplayAsLink = false ;
247- let protocolsAllowedAsLinks = [ 'file:///' , 'http://' , 'https://' , 'vscode://' ] ;
248-
249- if ( dataType === 'string' && protocolsAllowedAsLinks . some ( ( protocolPrefix ) => value . startsWith ( protocolPrefix ) ) ) {
250- shouldDisplayAsLink = true ;
247+ let shouldDisplayValueAsLink = false ;
248+ if (
249+ dataType === 'string' &&
250+ PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE . some ( protocolPrefix =>
251+ value . startsWith ( protocolPrefix ) ,
252+ )
253+ ) {
254+ shouldDisplayValueAsLink = true ;
251255 }
252256
253257 children = (
@@ -266,12 +270,16 @@ export default function KeyValue({
266270 path = { path }
267271 value = { value }
268272 />
273+ ) : shouldDisplayValueAsLink ? (
274+ < a
275+ className = { styles . Link }
276+ href = { value }
277+ target = "_blank"
278+ rel = "noopener noreferrer" >
279+ { displayValue }
280+ </ a >
269281 ) : (
270- ( shouldDisplayAsLink ) ? (
271- < a href = { value } target = "_blank" > { displayValue } </ a >
272- ) : (
273- < span className = { styles . Value } > { displayValue } </ span >
274- )
282+ < span className = { styles . Value } > { displayValue } </ span >
275283 ) }
276284 </ div >
277285 ) ;
0 commit comments