|
40 | 40 |
|
41 | 41 | <!-- Startup (do not modify order of script tags!) -->
|
42 | 42 | <script>
|
43 |
| - let nlsConfig |
44 |
| - try { |
45 |
| - nlsConfig = JSON.parse(document.getElementById("vscode-remote-nls-configuration").getAttribute("data-settings")) |
46 |
| - if (nlsConfig._resolvedLanguagePackCoreLocation) { |
47 |
| - const bundles = Object.create(null) |
48 |
| - nlsConfig.loadBundle = (bundle, _language, cb) => { |
49 |
| - const result = bundles[bundle] |
50 |
| - if (result) { |
51 |
| - return cb(undefined, result) |
52 |
| - } |
53 |
| - // FIXME: Only works if path separators are /. |
54 |
| - const path = nlsConfig._resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json" |
55 |
| - fetch(`${options.base}/vscode/resource/?path=${encodeURIComponent(path)}`) |
56 |
| - .then((response) => response.json()) |
57 |
| - .then((json) => { |
58 |
| - bundles[bundle] = json |
59 |
| - cb(undefined, json) |
60 |
| - }) |
61 |
| - .catch(cb) |
62 |
| - } |
63 |
| - } |
64 |
| - } catch (error) { |
65 |
| - /* Probably fine. */ |
| 43 | + const normalize = (url, keepTrailing = false) => { |
| 44 | + return url.replace(/\/\/+/g, "/").replace(/\/+$/, keepTrailing ? "/" : "") |
66 | 45 | }
|
| 46 | + |
67 | 47 | const resolveBase = (base) => {
|
68 | 48 | // After resolving the base will either start with / or be an empty string.
|
69 | 49 | if (!base || base.startsWith("/")) {
|
70 | 50 | return base ?? ""
|
71 | 51 | }
|
| 52 | + const parts = location.pathname.split("/") |
| 53 | + parts[parts.length - 1] = base |
| 54 | + const url = new URL(location.origin + "/" + parts.join("/")) |
| 55 | + return normalize(url.pathname) |
72 | 56 | }
|
73 | 57 |
|
74 | 58 | const base = resolveBase("{{CS_STATIC_BASE}}")
|
|
88 | 72 | "iconv-lite-umd": `../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`,
|
89 | 73 | jschardet: `../node_modules/jschardet/dist/jschardet.min.js`,
|
90 | 74 | },
|
91 |
| - "vs/nls": nlsConfig, |
92 | 75 | }
|
93 | 76 | </script>
|
94 | 77 | <!-- <script data-cfasync="false" type="module" src="{{CS_STATIC_BASE}}/out/browser/pages/vscode.browserified.js"></script> -->
|
|
0 commit comments