@@ -350,7 +350,9 @@ export async function terminalWithDocker(): Promise<vscode.Terminal> {
350350 * Alter isfs-type uri.path of /.vscode/* files or subdirectories.
351351 * Rewrite `/.vscode/path/to/file` as `/_vscode/XYZ/path/to/file`
352352 * 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
354356 *
355357 * @returns uri, altered if necessary.
356358 * @throws if `ns` queryparam is missing but required.
@@ -361,13 +363,24 @@ export function redirectDotvscodeRoot(uri: vscode.Uri): vscode.Uri {
361363 }
362364 const dotMatch = uri . path . match ( / ^ \/ ( \. [ ^ / ] * ) \/ ( .* ) $ / ) ;
363365 if ( dotMatch && dotMatch [ 1 ] === ".vscode" ) {
366+ let namespace : string ;
364367 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+ }
367382 }
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" ) ;
371384 } else {
372385 return uri ;
373386 }
0 commit comments