mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-22 03:10:43 +08:00
fix(ci): accept the CDN's effective manifest cache window
The CDN in front of aliyun-oss.yaklang.com rewrites JSON responses to max-age=60 (the browser-binaries manifest gets the same), which is stricter than the 300s we set at upload. Assert the effective window is short rather than matching the upload value.
This commit is contained in:
@@ -79,7 +79,12 @@ for (const artifact of entry.artifacts) {
|
||||
const manifestRes = await fetchOk(`${baseUrl}/manifest.json`);
|
||||
const manifestBytes = Buffer.from(await manifestRes.arrayBuffer());
|
||||
const manifestCache = manifestRes.headers.get('cache-control') ?? '';
|
||||
assert(manifestCache.includes('max-age=300'), `manifest.json: unexpected cache-control "${manifestCache}"`);
|
||||
// The CDN in front of aliyun-oss.yaklang.com rewrites JSON cache-control to
|
||||
// max-age=60 (the browser mirror gets the same treatment), so assert the
|
||||
// effective freshness window is short instead of matching our upload value.
|
||||
const manifestMaxAge = Number(/max-age=(\d+)/.exec(manifestCache)?.[1] ?? 0);
|
||||
assert(manifestMaxAge > 0 && manifestMaxAge <= 300,
|
||||
`manifest.json: unexpected cache-control "${manifestCache}"`);
|
||||
const manifest = JSON.parse(manifestBytes.toString('utf8'));
|
||||
assert(manifest.latest === entry.version, `manifest.latest ${manifest.latest} != ${entry.version}`);
|
||||
const versionEntry = manifest.versions.find((v) => v.version === entry.version);
|
||||
|
||||
Reference in New Issue
Block a user