Rocky_Mountain_Vending/lib/manuals-thumbnail-fallback.ts

14 lines
383 B
TypeScript

export function deriveThumbnailPathFromManualPath(
manualPath: string | undefined | null
): string | undefined {
const trimmedPath = String(manualPath || "").trim()
if (!trimmedPath || /^https?:\/\//i.test(trimmedPath)) {
return undefined
}
if (!trimmedPath.toLowerCase().endsWith(".pdf")) {
return undefined
}
return trimmedPath.replace(/\.pdf$/i, ".jpg")
}