Skip to content

Commit

Permalink
chore(unpkg): log headers and response length
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Oct 2, 2023
1 parent cb84b2c commit 6a9df01
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/unpkg.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function cleanupHeaders(resp) {
for (const kv of resp.headers.entries()) {
if (!removedHeaders.includes(kv[0])) {
newHeaders.append(kv[0], kv[1]);
console.log('keeping header', kv[0], kv[1]);
}
}

Expand All @@ -54,6 +55,7 @@ async function transformBody(resp, responseUrl, req) {
&& url.pathname.indexOf('@adobe/helix-rum-js') >= 0) {
const generation = url.searchParams.get('generation') || respURL.pathname.split(/[@\\/]/).slice(2, 5).join('-');
const text = await resp.text();
console.log('response length', text.length);
const body = text.replace(/__HELIX_RUM_JS_VERSION__/, generation.replace(/[^a-z0-9_.-]/ig, ''));
return new Response(body, { headers: resp.headers });
}
Expand Down

0 comments on commit 6a9df01

Please sign in to comment.