const OPTIMIZABLE_IMAGE_EXTENSIONS = /\.(avif|gif|jpe?g|png|webp)$/i;

// The Next.js image optimizer rejects SVG, and some S3 theme assets are SVG files stored with a `.bin` extension.
export function shouldSkipImageOptimization(src: string) {
  try {
    return !OPTIMIZABLE_IMAGE_EXTENSIONS.test(new URL(src, "http://localhost").pathname);
  } catch {
    return true;
  }
}
