Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

527 B
Raw Blame
import hash from "@emotion/hash";
import { type ResourceRequest } from "@webstudio-is/sdk";

export const getResourceKey = (resource: ResourceRequest) => {
  try {
    return hash(
      JSON.stringify([
        // explicitly list all fields to keep hash stable
        resource.name,
        resource.method,
        resource.url,
        resource.searchParams,
        resource.headers,
        resource.body,
        resource.bodyFormat,
      ])
    );
  } catch {
    // guard from invalid resources
    return "";
  }
};