Repository: prisma/prisma
File: packages/cli/src/Studio.ts (TypeScript)

Code before:
            default:
              throw new Error(`Unsupported runtime for SQLite: "${runtime}"`)
          }
        } catch (error: unknown) {
          throw new Error(
            `Failed to open SQLite database at "${resolvedPath}".\nCaused by: ${(error as Error).message}

Please use Node.js >=22.5, Deno >=2.2 or Bun >=1.0 or ensure you have the \`better-sqlite3\` package installed for Node.js <22.5 or the \`jsr:@db/sqlite\` package installed for Deno <2.2.`,
          )
        }
      }

      process.once('SIGINT', () => database!.close())
      process.once('SIGTERM', () => database!.close())

      return createNodeSQLiteExecutor(database)
    },
    reExportAdapterScript: `export { createSQLiteAdapter as ${ADAPTER_FACTORY_FUNCTION_NAME} } from '/data/sqlite-core/index.js';`,
  },
  postgres: POSTGRES_STUDIO_STUFF,
  postgresql: POSTGRES_STUDIO_STUFF,
  'prisma+postgres': {
    async createExecutor(connectionString, relativeTo) {
      const connectionURL = new URL(connectionString)

      if (['localhost', '127.0.0.1', '::1'].includes(connectionURL.hostname)) {
        // TODO: support `prisma dev` accelerate URLs.

        throw new Error('The "prisma+postgres" protocol with localhost is not supported in Prisma Studio yet.')
      }

      const apiKey = connectionURL.searchParams.get(ACCELERATE_API_KEY_QUERY_PARAMETER)

      if (!apiKey) {
        throw new Error(
          `\`${ACCELERATE_API_KEY_QUERY_PARAMETER}\` query parameter is missing in the provided "prisma+postgres" connection string.`,
        )
      }

      const [, payload] = apiKey.split('.')

      try {
        const decodedPayload = JSON.parse(Buffer.from(payload, 'base64').toString('utf-8'))

        if (
          typeof decodedPayload !== 'object' ||
          decodedPayload === null ||
          Array.isArray(decodedPayload) ||
          !('secure_key' in decodedPayload) ||
          typeof decodedPayload.secure_key !== 'string' ||
          !('tenant_id' in decodedPayload) ||

Review comment (suggestion):
```suggestion
      if (['localhost', '127.0.0.1', '[::1]'].includes(connectionURL.hostname)) {
```

Code after:
                Database: Database
              }

              database = new Database(resolvedPath) as never
              break
            }
            default:
              throw new Error(`Unsupported runtime for SQLite: "${runtime}"`)
          }
        } catch (error: unknown) {
          throw new Error(
            `Failed to open SQLite database at "${resolvedPath}".\nCaused by: ${(error as Error).message}

Please use Node.js >=22.5, Deno >=2.2 or Bun >=1.0 or ensure you have the \`better-sqlite3\` package installed for Node.js <22.5 or the \`jsr:@db/sqlite\` package installed for Deno <2.2.`,
          )
        }
      }

      process.once('SIGINT', () => database!.close())
      process.once('SIGTERM', () => database!.close())

      return createNodeSQLiteExecutor(database)
    },
    reExportAdapterScript: `export { createSQLiteAdapter as ${ADAPTER_FACTORY_FUNCTION_NAME} } from '/data/sqlite-core/index.js';`,
  },
  postgres: POSTGRES_STUDIO_STUFF,
  postgresql: POSTGRES_STUDIO_STUFF,
  'prisma+postgres': {
    async createExecutor(connectionString, relativeTo) {
      const connectionURL = new URL(connectionString)

      if (['localhost', '127.0.0.1', '[::1]'].includes(connectionURL.hostname)) {
        // TODO: support `prisma dev` accelerate URLs.

        throw new Error('The "prisma+postgres" protocol with localhost is not supported in Prisma Studio yet.')
      }

      const apiKey = connectionURL.searchParams.get(ACCELERATE_API_KEY_QUERY_PARAMETER)

      if (!apiKey) {
        throw new Error(
          `\`${ACCELERATE_API_KEY_QUERY_PARAMETER}\` query parameter is missing in the provided "prisma+postgres" connection string.`,
        )
      }

      const [, payload] = apiKey.split('.')

      try {
        const decodedPayload = AccelerateAPIKeyPayloadSchema.parse(
          JSON.parse(Buffer.from(payload, 'base64').toString('utf-8')),
        )