import { fileAttributeSchema, imageAttributeSchema } from "$/deps/strapi.ts"; const publicUrl = Deno.env.get("STRAPI_PUBLIC_URL") ?? Deno.env.get("STRAPI_URL"); export const resolvedFileAttributeSchema = fileAttributeSchema.pipe( ({ url, previewUrl, ...o }) => ({ ...o, url: new URL(url, publicUrl).href, ...(previewUrl ? { previewUrl: new URL(previewUrl, publicUrl).href } : {}), }), ); export const resolvedImageAttributeSchema = imageAttributeSchema.pipe((o) => ({ ...o, previewUrl: o.previewUrl ? new URL(o.previewUrl, publicUrl).href : undefined, url: new URL(o.url, publicUrl).href, }));