@@ -6,6 +6,7 @@ import * as util from "util";
66import * as url from "url" ;
77
88import { Emitter } from "vs/base/common/event" ;
9+ import { sanitizeFilePath } from "vs/base/common/extpath" ;
910import { getMediaMime } from "vs/base/common/mime" ;
1011import { extname } from "vs/base/common/path" ;
1112import { UriComponents , URI } from "vs/base/common/uri" ;
@@ -139,7 +140,8 @@ export class Server {
139140 ) ;
140141 }
141142
142- const requestPath = url . parse ( request . url || "" ) . pathname || "/" ;
143+ const parsedUrl = url . parse ( request . url || "" , true ) ;
144+ const requestPath = parsedUrl . pathname || "/" ;
143145 if ( requestPath === "/" ) {
144146 const htmlPath = path . join (
145147 this . rootPath ,
@@ -151,8 +153,14 @@ export class Server {
151153 const remoteAuthority = request . headers . host as string ;
152154 const transformer = getUriTransformer ( remoteAuthority ) ;
153155
156+ const cwd = process . env . VSCODE_CWD || process . cwd ( ) ;
157+ const workspacePath = parsedUrl . query . workspace as string | undefined ;
158+ const folderPath = ! workspacePath ? parsedUrl . query . folder as string | undefined || cwd : undefined ;
159+
154160 const options : Options = {
155161 WORKBENCH_WEB_CONGIGURATION : {
162+ workspaceUri : workspacePath ? transformer . transformOutgoing ( URI . file ( sanitizeFilePath ( workspacePath , cwd ) ) ) : undefined ,
163+ folderUri : folderPath ? transformer . transformOutgoing ( URI . file ( sanitizeFilePath ( folderPath , cwd ) ) ) : undefined ,
156164 remoteAuthority,
157165 } ,
158166 REMOTE_USER_DATA_URI : transformer . transformOutgoing ( this . environmentService . webUserDataHome ) ,
0 commit comments