Skip to content

Commit

Permalink
workspace: add url encoding
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 committed Aug 26, 2021
1 parent 1dba014 commit b0f0896
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 @@ -277,7 +277,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,6 +161,7 @@ export class WorkspaceService implements FrontendApplicationContribution {
* Set the URL fragment to the given workspace path.
*/
protected setURLFragment(workspacePath: string): void {
workspacePath = encodeURI(workspacePath);
window.location.hash = workspacePath;
}

Expand Down Expand Up @@ -500,13 +501,12 @@ export class WorkspaceService implements FrontendApplicationContribution {
} else {
this.setURLFragment('');
}

window.location.reload(true);
}

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 b0f0896

Please sign in to comment.