Skip to content

Commit b12dc91

Browse files
authored
Website: Preserve the mode query arg when opening OPFS site (#63)
When opening a non-temporary site, Playground removes all the query args from the URL to avoid running boot flows again, e.g. preserving `?blueprint-url=` would confuse the user at best, and corrupt the site at worst. Problem is, some query args are useful to preserve. For example, `mode=seamless` hides the "browser UI" and it's confusing when Playground immediately drops it from the URL. This PR preserves three benign query args: * mode * networking * login (which only sets a PHP const these days) ## Testing instructions * Create a new OPFS site * Open it * Add ?mode=seamless&networking=yes&login=yes&blueprint-url=https://mysite.com/blueprint.json to the URL * Confirm the first three query args were preserved and the blueprint-url was dropped
1 parent cc69f49 commit b12dc91

File tree

1 file changed

+9
-1
lines changed
  • packages/playground/website/src/lib/state/url

1 file changed

+9
-1
lines changed

packages/playground/website/src/lib/state/url/router.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,16 @@ export class PlaygroundRoute {
4141
if (site.metadata.storage === 'none') {
4242
return updateUrl(baseUrl, site.originalUrlParams || {});
4343
} else {
44+
const baseParams = new URLSearchParams(baseUrl.split('?')[1]);
45+
const preserveParamsKeys = ['mode', 'networking', 'login', 'url'];
46+
const preserveParams: Record<string, string | null> = {};
47+
for (const param of preserveParamsKeys) {
48+
if (baseParams.has(param)) {
49+
preserveParams[param] = baseParams.get(param);
50+
}
51+
}
4452
return updateUrl(baseUrl, {
45-
searchParams: { 'site-slug': site.slug },
53+
searchParams: { 'site-slug': site.slug, ...preserveParams },
4654
hash: '',
4755
});
4856
}

0 commit comments

Comments
 (0)