import path from "node:path"; export function resolveDocumentRkey(filePath: string, extension: string): string | null { if (filePath === "/") { return null; } const name = path.posix.basename(filePath); if (!name || !name.endsWith(extension)) { return null; } if (name.startsWith(".#") || name.startsWith("#") || name.endsWith("~") || name.endsWith("#")) { return null; } return name.slice(0, -extension.length); }