File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,13 @@ type NlsConfiguration = {
24
24
* Helper function to create the path to the bundle
25
25
* for getNlsConfiguration.
26
26
*/
27
- export function createBundlePath ( _resolvedLanguagePackCoreLocation : string , bundle : string ) {
27
+ export function createBundlePath ( _resolvedLanguagePackCoreLocation : string | undefined , bundle : string ) {
28
28
// NOTE@jsjoeio - this comment was here before me
29
29
// Refers to operating systems that use a different path separator.
30
30
// Probably just Windows but we're not sure if "/" breaks on Windows
31
31
// so we'll leave it alone for now.
32
32
// FIXME: Only works if path separators are /.
33
- return _resolvedLanguagePackCoreLocation + "/" + bundle . replace ( / \/ / g, "!" ) + ".nls.json"
33
+ return ( _resolvedLanguagePackCoreLocation || "" ) + "/" + bundle . replace ( / \/ / g, "!" ) + ".nls.json"
34
34
}
35
35
36
36
/**
@@ -80,7 +80,7 @@ export function getNlsConfiguration(_document: Document, base: string) {
80
80
}
81
81
// FIXME: Only works if path separators are /.
82
82
try {
83
- const path = createBundlePath ( nlsConfig . _resolvedLanguagePackCoreLocation || "" , bundle )
83
+ const path = createBundlePath ( nlsConfig . _resolvedLanguagePackCoreLocation , bundle )
84
84
const response = await fetch ( `${ base } /vscode/resource/?path=${ encodeURIComponent ( path ) } ` )
85
85
const json = await response . json ( )
86
86
bundles [ bundle ] = json
Original file line number Diff line number Diff line change @@ -115,6 +115,13 @@ describe("vscode", () => {
115
115
const actual = createBundlePath ( _resolvedLangaugePackCoreLocation , bundle )
116
116
expect ( actual ) . toBe ( expected )
117
117
} )
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
+ } )
118
125
} )
119
126
describe ( "setBodyBackgroundToThemeBackgroundColor" , ( ) => {
120
127
let _document : Document
@@ -310,7 +317,7 @@ describe("vscode", () => {
310
317
expect ( loader . trustedTypesPolicy . name ) . toBe ( "amdLoader" )
311
318
312
319
const scriptUrl = loader . trustedTypesPolicy . createScriptURL ( "http://localhost/foo.js" )
313
- expect ( scriptUrl ) . toBe ( "/foo.js" )
320
+ expect ( scriptUrl ) . toBe ( "http://localhost /foo.js" )
314
321
} )
315
322
} )
316
323
describe ( "_createScriptURL" , ( ) => {
You can’t perform that action at this time.
0 commit comments