Remove unnecessaries non-browser checks

This commit is contained in:
Adria Navarro
2026-08-26 17:19:26 +02:00
parent 116e4fb59f
commit 30a1915252
2 changed files with 6 additions and 6 deletions
+2
View File
@@ -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
@@ -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
}