Skip to content

Commit

Permalink
workspace: add url encoding (#9850)
Browse files Browse the repository at this point in the history
The commit introduces the use of `encoding` when we are loading/reloading a workspace URL.
Previously, the application would fail to open a workspace URL with reserved characters such as `%`.
  • Loading branch information
OmarSdt-EC authored and RomanNikitenko committed Sep 16, 2021
1 parent 7180770 commit 91d2b50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class ElectronMainApplication {
protected async openWindowWithWorkspace(workspacePath: string): Promise<BrowserWindow> {
const options = await this.getLastWindowOptions();
const [uri, electronWindow] = await Promise.all([this.createWindowUri(), this.createWindow(options)]);
electronWindow.loadURL(uri.withFragment(workspacePath).toString(true));
electronWindow.loadURL(uri.withFragment(encodeURI(workspacePath)).toString(true));
return electronWindow;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/workspace/src/browser/workspace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class WorkspaceService implements FrontendApplicationContribution {
* Set the URL fragment to the given workspace path.
*/
protected setURLFragment(workspacePath: string): void {
window.location.hash = workspacePath;
window.location.hash = encodeURI(workspacePath);
}

get roots(): Promise<FileStat[]> {
Expand Down Expand Up @@ -506,7 +506,7 @@ export class WorkspaceService implements FrontendApplicationContribution {

protected openNewWindow(workspacePath: string): void {
const url = new URL(window.location.href);
url.hash = workspacePath;
url.hash = encodeURI(workspacePath);
this.windowService.openNewWindow(url.toString());
}

Expand Down

0 comments on commit 91d2b50

Please sign in to comment.