Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devtools: Display as link if value is in specified protocols #21964

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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://'];
kkragoth marked this conversation as resolved.
Show resolved Hide resolved

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>
kkragoth marked this conversation as resolved.
Show resolved Hide resolved
) : (
<span className={styles.Value}>{displayValue}</span>
)
)}
</div>
);
Expand Down