@bigbinary/neeto-playwright-commons 4.1.12 → 4.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +25 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -116561,6 +116561,11 @@ class ColorPickerUtils {
|
|
|
116561
116561
|
}
|
|
116562
116562
|
|
|
116563
116563
|
const STATIC_ASSET_PATTERN = /\.(js|css|woff2?|ttf|eot|png|svg|ico|gif|webp)(\?.*)?$/;
|
|
116564
|
+
const EXCLUDED_RESPONSE_HEADERS = [
|
|
116565
|
+
"content-encoding",
|
|
116566
|
+
"content-length",
|
|
116567
|
+
"transfer-encoding",
|
|
116568
|
+
];
|
|
116564
116569
|
const assetCache = new Map();
|
|
116565
116570
|
const commands = {
|
|
116566
116571
|
context: async ({ context }, use) => {
|
|
@@ -116571,14 +116576,26 @@ const commands = {
|
|
|
116571
116576
|
if (hit)
|
|
116572
116577
|
return route.fulfill(hit);
|
|
116573
116578
|
try {
|
|
116574
|
-
|
|
116575
|
-
|
|
116576
|
-
|
|
116577
|
-
|
|
116578
|
-
|
|
116579
|
-
|
|
116580
|
-
|
|
116581
|
-
|
|
116579
|
+
// Use Node's native fetch instead of route.fetch() to keep these
|
|
116580
|
+
// requests out of the Playwright trace's Actions tab. Forward the
|
|
116581
|
+
// browser's request headers so cookie/session-scoped assets still
|
|
116582
|
+
// resolve; drop accept-encoding so we only get encodings Node can
|
|
116583
|
+
// decode, and HTTP/2 pseudo-headers which fetch rejects.
|
|
116584
|
+
const requestHeaders = Object.entries(await route.request().allHeaders()).filter(([name]) => name !== "accept-encoding" && !name.startsWith(":"));
|
|
116585
|
+
const response = await fetch(url, {
|
|
116586
|
+
headers: Object.fromEntries(requestHeaders),
|
|
116587
|
+
});
|
|
116588
|
+
const body = Buffer.from(await response.arrayBuffer());
|
|
116589
|
+
// Node's fetch decompresses the body but keeps the original
|
|
116590
|
+
// content-encoding/content-length headers; drop them so the
|
|
116591
|
+
// browser doesn't try to decode the already-decoded body.
|
|
116592
|
+
const headers = {};
|
|
116593
|
+
response.headers.forEach((value, key) => {
|
|
116594
|
+
if (!EXCLUDED_RESPONSE_HEADERS.includes(key))
|
|
116595
|
+
headers[key] = value;
|
|
116596
|
+
});
|
|
116597
|
+
const entry = { body, status: response.status, headers };
|
|
116598
|
+
if (response.ok)
|
|
116582
116599
|
assetCache.set(url, entry);
|
|
116583
116600
|
return route.fulfill(entry);
|
|
116584
116601
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-playwright-commons",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.13",
|
|
4
4
|
"description": "A package encapsulating common playwright code across neeto projects.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
|
|
6
6
|
"license": "apache-2.0",
|