Generates safe SQL file names and exports SQL content to disk or clipboard.
// Source: https://github.com/t8y2/dbx | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
import { ensureSqlExtension, stripSqlExtension } from "@/lib/savedSql/savedSqlFileName";
export function savedSqlExportFileName(name: string): string {
return (
ensureSqlExtension(name)
.replace(/[<>:"/\\|?*\p{Cc}]/gu, "_")
.trim() || "untitled.sql"
);
}
export function uniqueSavedSqlExportFileName(name: string, takenNames: Set<string>): string {
const normalized = savedSqlExportFileName(name);
const occupied = new Set([...takenNames].map((taken) => taken.toLocaleLowerCase()));
const base = stripSqlExtension
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key