diff --git a/CLAUDE.md b/CLAUDE.md index 9cb7ee15a9..ab176ba1a0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,6 +46,8 @@ against, provided there are no type errors. - Avoid adding nested ternary statements. - Prefer a svelte5 approach over svelte4. +- Builder code runs in a browser context, so do not guard browser globals such + as `window` with `typeof window === "undefined"` checks. - Don't use // @ts-nocheck when asked to fix type errors. - When writing tests involving a URL, use example.com as the domain. - Use object parameters for functions with multiple inputs. This is required for diff --git a/packages/builder/src/helpers/workspaceHomeNavigation.ts b/packages/builder/src/helpers/workspaceHomeNavigation.ts index 1dc9a43086..1967d87042 100644 --- a/packages/builder/src/helpers/workspaceHomeNavigation.ts +++ b/packages/builder/src/helpers/workspaceHomeNavigation.ts @@ -3,11 +3,9 @@ const buildHomePath = (workspaceId: string) => export const withWorkspaceHomeReturn = ( targetUrl: string, - homeUrl = new URLSearchParams( - typeof window === "undefined" ? "" : window.location.search - ).get("returnTo") + homeUrl = new URLSearchParams(window.location.search).get("returnTo") ) => { - if (!homeUrl || typeof window === "undefined") { + if (!homeUrl) { return targetUrl } @@ -23,11 +21,11 @@ export const withWorkspaceHomeReturn = ( export const getWorkspaceHomeUrl = ( workspaceId: string, - search = typeof window === "undefined" ? "" : window.location.search + search = window.location.search ) => { const fallbackUrl = buildHomePath(workspaceId) const returnTo = new URLSearchParams(search).get("returnTo") - if (!returnTo || typeof window === "undefined") { + if (!returnTo) { return fallbackUrl }