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
10 changes: 5 additions & 5 deletions external/ccov/coverage_search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,27 @@ async function refreshIndex() {
process.exit(1);
};

const headers = {};
const headers = new Headers();
if (hasCached && fs.existsSync(etagPath)) {
const etag = fs.readFileSync(etagPath, "utf8").trim();
// Only forward a syntactically valid HTTP ETag (RFC 7232), so the cached
// file's contents can't be used to inject arbitrary data into the request.
if (/^(?:W\/)?"[\x21\x23-\x7e]*"$/.test(etag)) {
headers["If-None-Match"] = etag;
headers.set("If-None-Match", etag);
}
}

let response;
try {
console.error(`Fetching per-test index from ${PER_TEST_INDEX_URL} ...`);
console.log(`Fetching per-test index from ${PER_TEST_INDEX_URL} ...`);
response = await fetch(PER_TEST_INDEX_URL, { headers });
} catch (error) {
fallbackOrFail(error.message);
return;
}

if (response.status === 304) {
console.error("Per-test index is up to date.");
console.log("Per-test index is up to date.");
return;
}
if (!response.ok) {
Expand Down Expand Up @@ -174,7 +174,7 @@ async function refreshIndex() {
fallbackOrFail(error.message);
return;
}
console.error(`Per-test index updated (${serialized.length} bytes).`);
console.log(`Per-test index updated (${serialized.length} bytes).`);
}

await refreshIndex();
Expand Down