Skip to content

Commit 889d476

Browse files
committed
wip!
1 parent 98dfac8 commit 889d476

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/browser/pages/vscode.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ type NlsConfiguration = {
2424
* Helper function to create the path to the bundle
2525
* for getNlsConfiguration.
2626
*/
27-
export function createBundlePath(_resolvedLanguagePackCoreLocation: string, bundle: string) {
27+
export function createBundlePath(_resolvedLanguagePackCoreLocation: string | undefined, bundle: string) {
2828
// NOTE@jsjoeio - this comment was here before me
2929
// Refers to operating systems that use a different path separator.
3030
// Probably just Windows but we're not sure if "/" breaks on Windows
3131
// so we'll leave it alone for now.
3232
// FIXME: Only works if path separators are /.
33-
return _resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json"
33+
return (_resolvedLanguagePackCoreLocation || "") + "/" + bundle.replace(/\//g, "!") + ".nls.json"
3434
}
3535

3636
/**
@@ -80,7 +80,7 @@ export function getNlsConfiguration(_document: Document, base: string) {
8080
}
8181
// FIXME: Only works if path separators are /.
8282
try {
83-
const path = createBundlePath(nlsConfig._resolvedLanguagePackCoreLocation || "", bundle)
83+
const path = createBundlePath(nlsConfig._resolvedLanguagePackCoreLocation, bundle)
8484
const response = await fetch(`${base}/vscode/resource/?path=${encodeURIComponent(path)}`)
8585
const json = await response.json()
8686
bundles[bundle] = json

test/unit/browser/pages/vscode.test.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ describe("vscode", () => {
115115
const actual = createBundlePath(_resolvedLangaugePackCoreLocation, bundle)
116116
expect(actual).toBe(expected)
117117
})
118+
it("should return the correct path (even if _resolvedLangaugePackCoreLocation is undefined)", () => {
119+
const _resolvedLangaugePackCoreLocation = undefined
120+
const bundle = "/bundle.js"
121+
const expected = "/!bundle.js.nls.json"
122+
const actual = createBundlePath(_resolvedLangaugePackCoreLocation, bundle)
123+
expect(actual).toBe(expected)
124+
})
118125
})
119126
describe("setBodyBackgroundToThemeBackgroundColor", () => {
120127
let _document: Document
@@ -310,7 +317,7 @@ describe("vscode", () => {
310317
expect(loader.trustedTypesPolicy.name).toBe("amdLoader")
311318

312319
const scriptUrl = loader.trustedTypesPolicy.createScriptURL("http://localhost/foo.js")
313-
expect(scriptUrl).toBe("/foo.js")
320+
expect(scriptUrl).toBe("http://localhost/foo.js")
314321
})
315322
})
316323
describe("_createScriptURL", () => {

0 commit comments

Comments
 (0)