import { getImgproxyUrl } from "./imgproxy"; /** * Verification script for imgproxy URL generation */ function testImgproxyUrl() { const testCases = [ { src: "https://picsum.photos/800/800", options: { width: 400, height: 300, resizing_type: "fill" as const }, description: "Remote URL with fill resizing", }, { src: "/images/avatar.jpg", options: { width: 100, extension: "webp" }, description: "Local path with extension conversion", }, { src: "https://example.com/image.png", options: { gravity: "no" }, description: "Remote URL with custom gravity", }, ]; console.log("๐Ÿงช Testing imgproxy URL generation...\n"); testCases.forEach((tc, i) => { const url = getImgproxyUrl(tc.src, tc.options); console.log(`Test Case ${i + 1}: ${tc.description}`); console.log(`Source: ${tc.src}`); console.log(`Result: ${url}`); // Basic validation if (url.startsWith("https://img.infra.mintel.me/unsafe/")) { console.log("โœ… Base URL and unsafe path correct"); } else { console.log("โŒ Base URL or unsafe path mismatch"); } if ( tc.options.width && url.includes( `rs:${tc.options.resizing_type || "fit"}:${tc.options.width}`, ) ) { console.log("โœ… Resizing options present"); } console.log("-------------------\n"); }); } // Mock environment for testing if not set if (!process.env.NEXT_PUBLIC_IMGPROXY_URL) { process.env.NEXT_PUBLIC_IMGPROXY_URL = "https://img.infra.mintel.me"; } if (!process.env.NEXT_PUBLIC_BASE_URL) { process.env.NEXT_PUBLIC_BASE_URL = "http://mintel.localhost"; } testImgproxyUrl();