Prefer using data-href if it exists on a markdown preview link

Fixes #101203
This commit is contained in:
Matt Bierner 2020-07-23 21:51:10 -07:00
parent db170566b8
commit 731f9c2563
2 changed files with 8 additions and 6 deletions

File diff suppressed because one or more lines are too long

View file

@ -163,13 +163,15 @@ document.addEventListener('click', event => {
return;
}
// Pass through known schemes
if (passThroughLinkSchemes.some(scheme => node.href.startsWith(scheme))) {
return;
let hrefText = node.getAttribute('data-href');
if (!hrefText) {
// Pass through known schemes
if (passThroughLinkSchemes.some(scheme => node.href.startsWith(scheme))) {
return;
}
hrefText = node.getAttribute('href');
}
const hrefText = node.getAttribute('data-href') || node.getAttribute('href');
// If original link doesn't look like a url, delegate back to VS Code to resolve
if (!/^[a-z\-]+:/i.test(hrefText)) {
messaging.postMessage('openLink', { href: hrefText });