Skip to content

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

fix(studio): strip one-shot content param from SQL editor URL (#47140)

Danny White7ff3264b5f5a
diff --git a/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx b/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
index b745fd9d666..bc1c42f030d 100644
--- a/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
@@ -259,7 +259,15 @@ const MonacoEditor = ({
project_id: project?.id,
})
snapV2.addSnippet({ projectRef: ref, snippet })
- router.push(`/project/${ref}/sql/${snippet.id}`, undefined, { shallow: true })
+ // When the editor was seeded from a `content` deep-link, replace rather
+ // than push. The caller navigated to `/sql/new?content=...` (a long,
+ // one-shot URL); replacing collapses it out of history so Back returns to
+ // the originating page instead of a wasted step that re-seeds the snippet.
+ if (router.query.content !== undefined) {
+ router.replace(`/project/${ref}/sql/${snippet.id}`, undefined, { shallow: true })
+ } else {
+ router.push(`/project/${ref}/sql/${snippet.id}`, undefined, { shallow: true })
+ }
}
setValue(value)
}