@percy/core 1.30.7-beta.0 → 1.30.7-beta.1

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/dist/discovery.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import logger from '@percy/logger';
2
2
  import Queue from './queue.js';
3
3
  import Page from './page.js';
4
- import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName, waitForTimeout, withRetries, waitForSelectorInsideBrowser } from './utils.js';
4
+ import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName, waitForTimeout, withRetries, waitForSelectorInsideBrowser, isGzipped } from './utils.js';
5
5
  import { sha256hash } from '@percy/client/utils';
6
6
  import Pako from 'pako';
7
7
 
@@ -222,8 +222,12 @@ function processSnapshotResources({
222
222
  })));
223
223
  if (process.env.PERCY_GZIP) {
224
224
  for (let index = 0; index < resources.length; index++) {
225
- resources[index].content = Pako.gzip(resources[index].content);
226
- resources[index].sha = sha256hash(resources[index].content);
225
+ const alreadyZipped = isGzipped(resources[index].content);
226
+ /* istanbul ignore next: very hard to mock true */
227
+ if (!alreadyZipped) {
228
+ resources[index].content = Pako.gzip(resources[index].content);
229
+ resources[index].sha = sha256hash(resources[index].content);
230
+ }
227
231
  }
228
232
  }
229
233
  return {
package/dist/utils.js CHANGED
@@ -389,6 +389,20 @@ export function redactSecrets(data) {
389
389
  export function base64encode(content) {
390
390
  return Buffer.from(content).toString('base64');
391
391
  }
392
+
393
+ // It checks if content is already gzipped or not.
394
+ // We don't want to gzip already gzipped content.
395
+ export function isGzipped(content) {
396
+ if (!(content instanceof Uint8Array || content instanceof ArrayBuffer)) {
397
+ return false;
398
+ }
399
+
400
+ // Ensure content is a Uint8Array
401
+ const data = content instanceof ArrayBuffer ? new Uint8Array(content) : content;
402
+
403
+ // Gzip magic number: 0x1f8b
404
+ return data.length > 2 && data[0] === 0x1f && data[1] === 0x8b;
405
+ }
392
406
  const RESERVED_CHARACTERS = {
393
407
  '%3A': ':',
394
408
  '%23': '#',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.30.7-beta.0",
3
+ "version": "1.30.7-beta.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,11 +43,11 @@
43
43
  "test:types": "tsd"
44
44
  },
45
45
  "dependencies": {
46
- "@percy/client": "1.30.7-beta.0",
47
- "@percy/config": "1.30.7-beta.0",
48
- "@percy/dom": "1.30.7-beta.0",
49
- "@percy/logger": "1.30.7-beta.0",
50
- "@percy/webdriver-utils": "1.30.7-beta.0",
46
+ "@percy/client": "1.30.7-beta.1",
47
+ "@percy/config": "1.30.7-beta.1",
48
+ "@percy/dom": "1.30.7-beta.1",
49
+ "@percy/logger": "1.30.7-beta.1",
50
+ "@percy/webdriver-utils": "1.30.7-beta.1",
51
51
  "content-disposition": "^0.5.4",
52
52
  "cross-spawn": "^7.0.3",
53
53
  "extract-zip": "^2.0.1",
@@ -60,5 +60,5 @@
60
60
  "ws": "^8.17.1",
61
61
  "yaml": "^2.4.1"
62
62
  },
63
- "gitHead": "4d589cecf982efeab69ea82881844447369a2af4"
63
+ "gitHead": "b9a15ba7853ff350b7d7b7c3364700e70ca66643"
64
64
  }