@@ -350,7 +350,9 @@ export async function terminalWithDocker(): Promise<vscode.Terminal> {
350
350
* Alter isfs-type uri.path of /.vscode/* files or subdirectories.
351
351
* Rewrite `/.vscode/path/to/file` as `/_vscode/XYZ/path/to/file`
352
352
* where XYZ comes from the `ns` queryparam of uri.
353
- * Also alter query to specify `ns=%SYS&csp=1`
353
+ * Also alter query to specify `ns=%SYS&csp=1`
354
+ * Also handles the alternative syntax isfs://server:namespace/
355
+ * in which there is no ns queryparam
354
356
*
355
357
* @returns uri, altered if necessary.
356
358
* @throws if `ns` queryparam is missing but required.
@@ -361,13 +363,24 @@ export function redirectDotvscodeRoot(uri: vscode.Uri): vscode.Uri {
361
363
}
362
364
const dotMatch = uri . path . match ( / ^ \/ ( \. [ ^ / ] * ) \/ ( .* ) $ / ) ;
363
365
if ( dotMatch && dotMatch [ 1 ] === ".vscode" ) {
366
+ let namespace : string ;
364
367
const nsMatch = `&${ uri . query } &` . match ( / & n s = ( [ ^ & ] + ) & / ) ;
365
- if ( ! nsMatch ) {
366
- throw new Error ( "No 'ns' query parameter on uri" ) ;
368
+ if ( nsMatch ) {
369
+ namespace = nsMatch [ 1 ] ;
370
+ const newQueryString = ( ( "&" + uri . query ) . replace ( `ns=${ namespace } ` , "ns=%SYS" ) + "&csp=1" ) . slice ( 1 ) ;
371
+ return uri . with ( { path : `/_vscode/${ namespace } /${ dotMatch [ 2 ] } ` , query : newQueryString } ) ;
372
+ } else {
373
+ const parts = uri . authority . split ( ":" ) ;
374
+ if ( parts . length === 2 ) {
375
+ namespace = parts [ 1 ] ;
376
+ return uri . with ( {
377
+ authority : `${ parts [ 0 ] } :%SYS` ,
378
+ path : `/_vscode/${ namespace } /${ dotMatch [ 2 ] } ` ,
379
+ query : uri . query + "&csp=1" ,
380
+ } ) ;
381
+ }
367
382
}
368
- const namespace = nsMatch [ 1 ] ;
369
- const newQueryString = ( ( "&" + uri . query ) . replace ( `ns=${ namespace } ` , "ns=%SYS" ) + "&csp=1" ) . slice ( 1 ) ;
370
- return uri . with ( { path : `/_vscode/${ namespace } /${ dotMatch [ 2 ] } ` , query : newQueryString } ) ;
383
+ throw new Error ( "No namespace determined from uri" ) ;
371
384
} else {
372
385
return uri ;
373
386
}
0 commit comments