Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: double ? on sign in urls (#34023)

Alaister Young1cf813b61a85
diff --git a/apps/studio/lib/gotrue.ts b/apps/studio/lib/gotrue.ts
index 2556bf4e12d..ba374101aa0 100644
--- a/apps/studio/lib/gotrue.ts
+++ b/apps/studio/lib/gotrue.ts
@@ -37,8 +37,19 @@ export const getIdentity = (gotrueUser: User) => {
* Transfers the search params from the current location path to a newly built path
*/
export const buildPathWithParams = (pathname: string) => {
- const searchParams = new URLSearchParams(location.search)
- return `${pathname}?${searchParams.toString()}`
+ const [basePath, existingParams] = pathname.split('?', 2)
+
+ const pathnameSearchParams = new URLSearchParams(existingParams || '')
+
+ // Merge the parameters, with pathname parameters taking precedence
+ // over the current location's search parameters
+ const mergedParams = new URLSearchParams(location.search)
+ for (const [key, value] of pathnameSearchParams.entries()) {
+ mergedParams.set(key, value)
+ }
+
+ const queryString = mergedParams.toString()
+ return queryString ? `${basePath}?${queryString}` : basePath
}
export const getReturnToPath = (fallback = '/projects') => {