Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

562 B
Raw Blame
import { buildProjectApiPath } from "./projectRouting";

/** Resolve a media src to its project-relative preview path, or null. */
export function resolvePreviewRelative(
  src: string | undefined,
  pid: string,
  origin: string,
): string | null {
  if (!src) return null;
  try {
    const parsed = new URL(src, origin);
    const base = new URL(buildProjectApiPath(pid, `/preview/`), origin).pathname;
    return parsed.pathname.startsWith(base)
      ? decodeURIComponent(parsed.pathname.slice(base.length))
      : null;
  } catch {
    return null;
  }
}