@percy/core 1.29.1-beta.1 → 1.29.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/network.js +1 -12
- package/dist/snapshot.js +3 -20
- package/dist/utils.js +0 -29
- package/package.json +8 -8
package/dist/network.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request as makeRequest } from '@percy/client/utils';
|
|
2
2
|
import logger from '@percy/logger';
|
|
3
3
|
import mime from 'mime-types';
|
|
4
|
-
import { DefaultMap, createResource,
|
|
4
|
+
import { DefaultMap, createResource, hostnameMatches, normalizeURL, waitFor } from './utils.js';
|
|
5
5
|
const MAX_RESOURCE_SIZE = 25 * 1024 ** 2; // 25MB
|
|
6
6
|
const ALLOWED_STATUSES = [200, 201, 301, 302, 304, 307, 308];
|
|
7
7
|
const ALLOWED_RESOURCES = ['Document', 'Stylesheet', 'Image', 'Media', 'Font', 'Other'];
|
|
@@ -213,17 +213,6 @@ export class Network {
|
|
|
213
213
|
|
|
214
214
|
// do not handle data urls
|
|
215
215
|
if (request.url.startsWith('data:')) return;
|
|
216
|
-
|
|
217
|
-
// Browsers handle URL encoding leniently, but invalid characters can break tools like Jackproxy.
|
|
218
|
-
// This code checks for issues such as `%` and leading spaces and warns the user accordingly.
|
|
219
|
-
decodeAndEncodeURLWithLogging(request.url, this.log, {
|
|
220
|
-
meta: {
|
|
221
|
-
...this.meta,
|
|
222
|
-
url: request.url
|
|
223
|
-
},
|
|
224
|
-
shouldLogWarning: true,
|
|
225
|
-
warningMessage: `An invalid URL was detected for url: ${request.url} - the snapshot may fail on Percy. Please verify that your asset URL is valid.`
|
|
226
|
-
});
|
|
227
216
|
if (this.intercept) {
|
|
228
217
|
this.#pending.set(requestId, event);
|
|
229
218
|
if (this.captureMockedServiceWorker) {
|
package/dist/snapshot.js
CHANGED
|
@@ -3,7 +3,7 @@ import PercyConfig from '@percy/config';
|
|
|
3
3
|
import micromatch from 'micromatch';
|
|
4
4
|
import { configSchema } from './config.js';
|
|
5
5
|
import Queue from './queue.js';
|
|
6
|
-
import { request, hostnameMatches, yieldTo, snapshotLogName
|
|
6
|
+
import { request, hostnameMatches, yieldTo, snapshotLogName } from './utils.js';
|
|
7
7
|
import { JobData } from './wait-for-job.js';
|
|
8
8
|
|
|
9
9
|
// Throw a better error message for missing or invalid urls
|
|
@@ -17,23 +17,6 @@ function validURL(url, base) {
|
|
|
17
17
|
throw new Error(`Invalid snapshot URL: ${e.input}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function validateAndFixSnapshotUrl(snapshot) {
|
|
21
|
-
let log = logger('core:snapshot');
|
|
22
|
-
// encoding snapshot url, if contians invalid URI characters/syntax
|
|
23
|
-
let modifiedURL = decodeAndEncodeURLWithLogging(snapshot.url, log, {
|
|
24
|
-
meta: {
|
|
25
|
-
snapshot: {
|
|
26
|
-
name: snapshot.name || snapshot.url
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
shouldLogWarning: true,
|
|
30
|
-
warningMessage: `Invalid URL detected for url: ${snapshot.url} - the snapshot may fail on Percy. Please confirm that your website URL is valid.`
|
|
31
|
-
});
|
|
32
|
-
if (modifiedURL !== snapshot.url) {
|
|
33
|
-
log.debug(`Snapshot URL modified to: ${modifiedURL}`);
|
|
34
|
-
snapshot.url = modifiedURL;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
20
|
|
|
38
21
|
// used to deserialize regular expression strings
|
|
39
22
|
const RE_REGEXP = /^\/(.+)\/(\w+)?$/;
|
|
@@ -103,9 +86,9 @@ function mapSnapshotOptions(snapshots, context) {
|
|
|
103
86
|
if (typeof snapshot === 'string') snapshot = {
|
|
104
87
|
url: snapshot
|
|
105
88
|
};
|
|
106
|
-
|
|
107
|
-
let url = validURL(snapshot.url, context === null || context === void 0 ? void 0 : context.baseUrl);
|
|
89
|
+
|
|
108
90
|
// normalize the snapshot url and use it for the default name
|
|
91
|
+
let url = validURL(snapshot.url, context === null || context === void 0 ? void 0 : context.baseUrl);
|
|
109
92
|
(_snapshot = snapshot).name || (_snapshot.name = `${url.pathname}${url.search}${url.hash}`);
|
|
110
93
|
snapshot.url = url.href;
|
|
111
94
|
|
package/dist/utils.js
CHANGED
|
@@ -379,35 +379,6 @@ export function redactSecrets(data) {
|
|
|
379
379
|
export function base64encode(content) {
|
|
380
380
|
return Buffer.from(content).toString('base64');
|
|
381
381
|
}
|
|
382
|
-
|
|
383
|
-
// This function replaces invalid character that are not the
|
|
384
|
-
// part of valid URI syntax with there correct encoded value.
|
|
385
|
-
// Also, if a character is a part of valid URI syntax, those characters
|
|
386
|
-
// are not encoded
|
|
387
|
-
// Eg: [abc] -> gets encoded to %5Babc%5D
|
|
388
|
-
// ab c -> ab%20c
|
|
389
|
-
export function decodeAndEncodeURLWithLogging(url, logger, options = {}) {
|
|
390
|
-
// In case the url is partially encoded, then directly using encodeURI()
|
|
391
|
-
// will encode those characters again. Therefore decodeURI once helps is decoding
|
|
392
|
-
// partially encoded URL and then after encoding it again, full URL get encoded
|
|
393
|
-
// correctly.
|
|
394
|
-
const {
|
|
395
|
-
meta,
|
|
396
|
-
shouldLogWarning,
|
|
397
|
-
warningMessage
|
|
398
|
-
} = options;
|
|
399
|
-
try {
|
|
400
|
-
let decodedURL = decodeURI(url); // This can throw error, so handle it will trycatch
|
|
401
|
-
let encodedURL = encodeURI(decodedURL);
|
|
402
|
-
return encodedURL;
|
|
403
|
-
} catch (error) {
|
|
404
|
-
logger.debug(error, meta);
|
|
405
|
-
if (error.name === 'URIError' && shouldLogWarning) {
|
|
406
|
-
logger.warn(warningMessage);
|
|
407
|
-
}
|
|
408
|
-
return url;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
382
|
export function snapshotLogName(name, meta) {
|
|
412
383
|
var _meta$snapshot;
|
|
413
384
|
if (meta !== null && meta !== void 0 && (_meta$snapshot = meta.snapshot) !== null && _meta$snapshot !== void 0 && _meta$snapshot.testCase) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.29.1
|
|
3
|
+
"version": "1.29.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "latest"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.29.1
|
|
47
|
-
"@percy/config": "1.29.1
|
|
48
|
-
"@percy/dom": "1.29.1
|
|
49
|
-
"@percy/logger": "1.29.1
|
|
50
|
-
"@percy/webdriver-utils": "1.29.1
|
|
46
|
+
"@percy/client": "1.29.1",
|
|
47
|
+
"@percy/config": "1.29.1",
|
|
48
|
+
"@percy/dom": "1.29.1",
|
|
49
|
+
"@percy/logger": "1.29.1",
|
|
50
|
+
"@percy/webdriver-utils": "1.29.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": "
|
|
63
|
+
"gitHead": "a2f1abdeb72e34cdc82f9d684902b38a8e7e0957"
|
|
64
64
|
}
|