Skip to content

Commit

Permalink
Devtools: Display as link if value is in specified protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
kkragoth committed Jul 26, 2021
1 parent 4758e45 commit 847f967
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ export default function KeyValue({
displayValue = 'undefined';
}

let shouldDisplayAsLink = false;
let protocolsAllowedAsLinks = ['file:///', 'http://', 'https://', 'vscode://'];

if (dataType === 'string' && protocolsAllowedAsLinks.some((protocolPrefix) => value.startsWith(protocolPrefix))) {
shouldDisplayAsLink = true;
}

children = (
<div
key="root"
Expand All @@ -260,7 +267,11 @@ export default function KeyValue({
value={value}
/>
) : (
<span className={styles.Value}>{displayValue}</span>
(shouldDisplayAsLink) ? (
<a href={value} target="_blank">{displayValue}</a>
) : (
<span className={styles.Value}>{displayValue}</span>
)
)}
</div>
);
Expand Down

0 comments on commit 847f967

Please sign in to comment.