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
16 changes: 15 additions & 1 deletion scripts/check-control-api-staging.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@ async function request(path, init = {}) {
signal: AbortSignal.timeout(10_000),
...init
});
if (!response.ok) throw new Error(path + " returned HTTP " + response.status);
if (!response.ok) {
Comment thread
zskbot marked this conversation as resolved.
Resolved
const body = (await response.text()).replace(/\\s+/g, " ").slice(0, 360);
Comment thread
zskbot marked this conversation as resolved.
Resolved
Comment thread
zskbot marked this conversation as resolved.
Resolved
Comment thread
zskbot marked this conversation as resolved.
Resolved
Comment thread
zskbot marked this conversation as resolved.
Resolved
const location = response.headers.get("location");
const safeLocation = location ? (() => { try { const u = new URL(location); return u.origin + u.pathname; } catch { return "present"; } })() : null;
Comment thread
zskbot marked this conversation as resolved.
Resolved
throw new Error(JSON.stringify({
path,
status: response.status,
finalUrl: new URL(response.url).origin + new URL(response.url).pathname,
Comment thread
zskbot marked this conversation as resolved.
Resolved
server: response.headers.get("server"),
cfMitigated: response.headers.get("cf-mitigated"),
contentType: response.headers.get("content-type"),
location: safeLocation,
body
}));
}
return response;
}

Expand Down
Loading