mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
Skip URL parsing when rendering empty links in Notebooks. (#6889)
This commit is contained in:
@@ -478,10 +478,7 @@ namespace Private {
|
||||
let anchors = node.getElementsByTagName('a');
|
||||
for (let i = 0; i < anchors.length; i++) {
|
||||
let path = anchors[i].href || '';
|
||||
const isLocal =
|
||||
resolver && resolver.isLocal
|
||||
? resolver.isLocal(path)
|
||||
: URLExt.isLocal(path);
|
||||
let isLocal = isPathLocal(path, resolver);
|
||||
if (isLocal) {
|
||||
anchors[i].target = '_self';
|
||||
} else {
|
||||
@@ -568,9 +565,7 @@ namespace Private {
|
||||
resolver: IRenderMime.IResolver
|
||||
): Promise<void> {
|
||||
let source = node.getAttribute(name) || '';
|
||||
const isLocal = resolver.isLocal
|
||||
? resolver.isLocal(source)
|
||||
: URLExt.isLocal(source);
|
||||
let isLocal = isPathLocal(source, resolver);
|
||||
if (!source || !isLocal) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
@@ -607,9 +602,7 @@ namespace Private {
|
||||
// Get the link path without the location prepended.
|
||||
// (e.g. "./foo.md#Header 1" vs "http://localhost:8888/foo.md#Header 1")
|
||||
let href = anchor.getAttribute('href') || '';
|
||||
const isLocal = resolver.isLocal
|
||||
? resolver.isLocal(href)
|
||||
: URLExt.isLocal(href);
|
||||
let isLocal = isPathLocal(href, resolver);
|
||||
// Bail if it is not a file-like url.
|
||||
if (!href || !isLocal) {
|
||||
return Promise.resolve(undefined);
|
||||
@@ -646,4 +639,17 @@ namespace Private {
|
||||
anchor.href = '';
|
||||
});
|
||||
}
|
||||
|
||||
function isPathLocal(path: string, resolver: IRenderMime.IResolver): boolean {
|
||||
let isLocal: boolean;
|
||||
if (path && path.length > 0) {
|
||||
isLocal = resolver && resolver.isLocal
|
||||
? resolver.isLocal(path)
|
||||
: URLExt.isLocal(path);
|
||||
} else {
|
||||
// Empty string, so default to local
|
||||
isLocal = true;
|
||||
}
|
||||
return isLocal;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user