Files
kandev/apps/web/lib/utils/copy-repository-path.ts
2026-09-24 19:05:37 +01:00

11 lines
408 B
TypeScript

import { copyToClipboard } from "./copy-to-clipboard";
const unsafeRepositoryPathControlCharacter = /[\u0000-\u001f\u007f]/;
export type CopyPathResult = "copied" | "unsafe" | "failed";
export async function copyPathToClipboard(path: string): Promise<CopyPathResult> {
if (unsafeRepositoryPathControlCharacter.test(path)) return "unsafe";
return (await copyToClipboard(path)) ? "copied" : "failed";
}