Skip to content

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

fix: omit quotes in values when `.env` contents are pasted into input (#39497)

Matt Johnston68fbcad6cff2
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretForm.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretForm.tsx
index 880542bdf43..237f6b381a0 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretForm.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretForm.tsx
@@ -48,6 +48,14 @@ const FormSchema = z.object({
const defaultValues = {
secrets: [{ name: '', value: '' }],
}
+
+const removeWrappingQuotes = (str: string): string => {
+ if ((str.startsWith('"') && str.endsWith('"')) || (str.startsWith("'") && str.endsWith("'"))) {
+ return str.slice(1, -1)
+ }
+ return str
+}
+
const AddNewSecretForm = () => {
const { ref: projectRef } = useParams()
const [showSecretValue, setShowSecretValue] = useState(false)
@@ -102,9 +110,10 @@ const AddNewSecretForm = () => {
lines.forEach((line) => {
const [key, ...valueParts] = line.split('=')
if (key && valueParts.length) {
+ const valueStr = valueParts.join('=').trim()
pairs.push({
name: key.trim(),
- value: valueParts.join('=').trim(),
+ value: removeWrappingQuotes(valueStr),
})
}
})