Skip to content

Commit 6d09566

Browse files
Allow multipage apps in puterjs (#1368)
* Allow multipage apps in puterjs * Don't error on browsers which dont support sessionStorage
1 parent e14e1ac commit 6d09566

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/puter-js/src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ export default globalThis.puter = (function() {
126126
context.services = this.services;
127127

128128
// Holds the query parameters found in the current URL
129-
let URLParams = new URLSearchParams(globalThis.location?.search);
129+
let URLParams = new URLSearchParams(globalThis.sessionStorage?.getItem("puter_search_params") || globalThis.location?.search);
130130

131131
// Figure out the environment in which the SDK is running
132-
if (URLParams.has('puter.app_instance_id'))
132+
if (URLParams.has('puter.app_instance_id')) {
133+
globalThis.sessionStorage?.setItem("puter_search_params", globalThis.sessionStorage?.getItem("puter_search_params") || globalThis.location?.search)
133134
this.env = 'app';
134-
else if(globalThis.puter_gui_enabled === true)
135+
} else if(globalThis.puter_gui_enabled === true)
135136
this.env = 'gui';
136137
else if (globalThis.WorkerGlobalScope) {
137138
if (globalThis.ServiceWorkerGlobalScope) {

0 commit comments

Comments
 (0)