mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-28 23:57:17 +09:00
22 lines
498 B
TypeScript
22 lines
498 B
TypeScript
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,
|
|
])
|
|
);
|
|
} catch {
|
|
// guard from invalid resources
|
|
return "";
|
|
}
|
|
};
|