Skip to content

Commit

Permalink
[workspace] Better localstorage keys #904
Browse files Browse the repository at this point in the history
Adds the current `window.location.pathname` in the key used to store data into the local storage.

This fixes an issue where multiple theia behind a proxy would share the same local storage domain.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
paul-marechal committed May 18, 2018
1 parent 6c696ae commit 0af1543
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/browser/storage-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ interface LocalStorage {
export class LocalStorageService implements StorageService {
private storage: LocalStorage;

constructor(@inject(ILogger) protected logger: ILogger) {
constructor(
@inject(ILogger) protected logger: ILogger
) {
if (typeof window !== 'undefined' && window.localStorage) {
this.storage = window.localStorage;
} else {
Expand All @@ -62,6 +64,7 @@ export class LocalStorageService implements StorageService {
}

protected prefix(key: string): string {
return 'theia:' + key;
const pathname = typeof window === 'undefined' ? '' : window.location.pathname;
return `theia:${pathname}:${key}`;
}
}

0 comments on commit 0af1543

Please sign in to comment.