forked from jupyter/notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublicpath.js
37 lines (33 loc) · 1.31 KB
/
publicpath.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// We dynamically set the webpack public path based on the page config
// settings from the JupyterLab app. We copy some of the pageconfig parsing
// logic in @jupyterlab/coreutils below, since this must run before any other
// files are loaded (including @jupyterlab/coreutils).
/**
* Get global configuration data for the Jupyter application.
*
* @param name - The name of the configuration option.
*
* @returns The config value or an empty string if not found.
*
* #### Notes
* All values are treated as strings.
* For browser based applications, it is assumed that the page HTML
* includes a script tag with the id `jupyter-config-data` containing the
* configuration as valid JSON. In order to support the classic Notebook,
* we fall back on checking for `body` data of the given `name`.
*/
function getOption(name) {
let configData = Object.create(null);
// Use script tag if available.
if (typeof document !== 'undefined' && document) {
const el = document.getElementById('jupyter-config-data');
if (el) {
configData = JSON.parse(el.textContent || '{}');
}
}
return configData[name] || '';
}
// eslint-disable-next-line no-undef
__webpack_public_path__ = getOption('fullStaticUrl') + '/';