// a full commit hash, and the raw /commit/<hash>.patch|.diff specs. a leaf module, no
// imports: src/params.ts matches routes with it, and kit loads that file outside vite
// go-git's IsHash accepts uppercase hex too (hex.DecodeString), both sha1
// and sha256 match case-insensitively
export const FULL_HASH_RE = /^([0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/;
export const parseRawCommit = (spec: string): { ref: string; format: "patch" | "diff" } | null => {
const dot = spec.lastIndexOf(".");
if (dot === -1) return null;
const format = spec.slice(dot + 1);
if (format !== "patch" && format !== "diff") return null;
const ref = spec.slice(0, dot);
return FULL_HASH_RE.test(ref) ? { ref, format } : null;
};