本文整理匯總了TypeScript中@jupyterlab/coreutils.URLExt.parse方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript URLExt.parse方法的具體用法?TypeScript URLExt.parse怎麽用?TypeScript URLExt.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@jupyterlab/coreutils.URLExt
的用法示例。
在下文中一共展示了URLExt.parse方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should handle query and hash', () => {
const url = "http://example.com/path?that's#all, folks";
const obj = URLExt.parse(url);
try {
expect(obj.href).to.equal(
'http://example.com/path?that%27s#all,%20folks'
);
} catch (e) {
// Chrome
expect(obj.href).to.equal(
'http://example.com/path?that%27s#all, folks'
);
}
expect(obj.protocol).to.equal('http:');
expect(obj.host).to.equal('example.com');
expect(obj.hostname).to.equal('example.com');
expect(obj.search).to.equal('?that%27s');
expect(obj.pathname).to.equal('/path');
try {
expect(obj.hash).to.equal('#all,%20folks');
} catch (e) {
// Chrome
expect(obj.hash).to.equal('#all, folks');
}
});
示例2: Date
.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);
})
示例3: handleAttr
/**
* Handle a node with a `src` or `href` attribute.
*/
function handleAttr(node: HTMLElement, name: 'src' | 'href', resolver: IRenderMime.IResolver): Promise<void> {
let source = node.getAttribute(name);
if (!source || URLExt.parse(source).protocol === 'data:') {
return Promise.resolve(undefined);
}
node.setAttribute(name, '');
return resolver.resolveUrl(source).then(path => {
return resolver.getDownloadUrl(path);
}).then(url => {
node.setAttribute(name, url);
});
}
示例4: newClosableIFrame
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 iframe = newClosableIFrame(url, text);
shell.addToMainArea(iframe);
tracker.activate(iframe);
}
示例5: handleAttr
/**
* Handle a node with a `src` or `href` attribute.
*/
function handleAttr(node: HTMLElement, name: 'src' | 'href', resolver: IRenderMime.IResolver): Promise<void> {
let source = node.getAttribute(name);
if (!source || URLExt.parse(source).protocol === 'data:') {
return Promise.resolve(undefined);
}
node.setAttribute(name, '');
return resolver.resolveUrl(source).then(path => {
return resolver.getDownloadUrl(path);
}).then(url => {
node.setAttribute(name, url);
}).catch(err => {
// If there was an error getting the url,
// just make it an empty link.
node.setAttribute(name, '');
});
}
示例6: handleAttr
/**
* Handle a node with a `src` or `href` attribute.
*/
function handleAttr(node: HTMLElement, name: 'src' | 'href', resolver: IRenderMime.IResolver): Promise<void> {
let source = node.getAttribute(name);
if (!source || URLExt.parse(source).protocol === 'data:') {
return Promise.resolve(undefined);
}
node.setAttribute(name, '');
return resolver.resolveUrl(source).then(path => {
return resolver.getDownloadUrl(path);
}).then(url => {
// 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 => {
// If there was an error getting the url,
// just make it an empty link.
node.setAttribute(name, '');
});
}
示例7:
handleLink: (node: HTMLElement, path: string) => {
if (!URLExt.parse(path).protocol && path.indexOf('//') !== 0) {
linker.connectNode(node, 'file-operations:open', { path });
}
}