Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(url => {
// Check protocol again in case it changed:
if (URLExt.parse(url).protocol !== 'data:') {
// Bust caching for local src attrs.
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
url += (/\?/.test(url) ? '&' : '?') + new Date().getTime();
}
node.setAttribute(name, url);
})
.catch(err => {
.then(url => {
// Check protocol again in case it changed:
if (URLExt.parse(url).protocol !== 'data:') {
// Bust caching for local src attrs.
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
url += (/\?/.test(url) ? '&' : '?') + new Date().getTime();
}
node.setAttribute(name, url);
})
.catch(err => {
.then(url => {
// Check protocol again in case it changed:
if (URLExt.parse(url).protocol !== 'data:') {
// Bust caching for local src attrs.
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
url += (/\?/.test(url) ? '&' : '?') + new Date().getTime();
}
node.setAttribute(name, url);
})
.catch(err => {
execute: args => {
const url = args['url'] as string;
const text = args['text'] as string;
// If help resource will generate a mixed content error, load externally.
if (LAB_IS_SECURE && URLExt.parse(url).protocol !== 'https:') {
window.open(url);
return;
}
let widget = newHelpWidget(url, text);
void tracker.add(widget);
shell.add(widget, 'main');
return widget;
}
});
it('should parse a url into a URLExt object', () => {
const obj = URLExt.parse('http://www.example.com');
expect(obj.href).to.equal('http://www.example.com/');
expect(obj.protocol).to.equal('http:');
expect(obj.host).to.equal('www.example.com');
expect(obj.hostname).to.equal('www.example.com');
expect(obj.pathname).to.equal('/');
});
export function isLocal(url: string): boolean {
const { protocol } = URLExt.parse(url);
return (
url.toLowerCase().indexOf(protocol!) !== 0 && url.indexOf('//') !== 0
);
}
}
get current(): IRouter.ILocation {
const { base } = this;
const parsed = URLExt.parse(window.location.href);
const { search, hash } = parsed;
const path = parsed.pathname.replace(base, '/');
const request = path + search + hash;
return { hash, path, request, search };
}
get current(): IRouter.ILocation {
const { base } = this;
const parsed = URLExt.parse(window.location.href);
const { search, hash } = parsed;
const path = parsed.pathname?.replace(base, '/') ?? '';
const request = path + search + hash;
return { hash, path, request, search };
}