mirror of
https://github.com/Budibase/budibase.git
synced 2026-08-28 19:01:11 +08:00
Remove unnecessaries non-browser checks
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user