Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/uploadAssets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Uploads contributor-added images under src/assets/{tokens,vaults,validators}
* Uploads contributor-added images under
* src/assets/{tokens,vaults,validators,protocols}
* to Cloudflare Images. Intended to run inside the `upload-assets` CI job after
* a maintainer has approved the `cloudflare-uploads` environment deployment.
*
Expand Down Expand Up @@ -51,7 +52,7 @@ if (
process.exit(1);
}

const ALLOWED_TYPES = ["tokens", "vaults", "validators"] as const;
const ALLOWED_TYPES = ["tokens", "vaults", "validators", "protocols"] as const;
type AssetType = (typeof ALLOWED_TYPES)[number];

const ALLOWED_EXTENSIONS = [".png", ".jpg", ".jpeg"] as const;
Expand Down Expand Up @@ -179,6 +180,14 @@ const validatePath = (relPath: string): FileCheckOk | FileCheckErr => {
reason: "filename must be 0x + 96 hex chars (validator pubkey)",
};
}
} else if (type === "protocols") {
if (!/^[a-z0-9-]+$/.test(basename)) {
return {
ok: false,
reason:
"filename must be a lowercase protocol slug (letters, numbers, and hyphens)",
};
}
} else {
// tokens or vaults
if (!/^0x[0-9a-f]{40}$/.test(basename)) {
Expand Down
Loading