@percy/core 1.32.11 → 1.32.12-beta.0

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.
Files changed (2) hide show
  1. package/dist/discovery.js +28 -3
  2. package/package.json +11 -11
package/dist/discovery.js CHANGED
@@ -508,8 +508,33 @@ function readWarnThresholdBytes() {
508
508
  // the actual coldest entry if needed. DISK_SPILL_KEY is only set when the
509
509
  // ByteLRU tier is active (see createDiscoveryQueue 'start' handler), so the
510
510
  // cache here is guaranteed to be a ByteLRU when we enter this branch.
511
- export function lookupCacheResource(percy, snapshotResources, cache, url, width) {
512
- let resource = snapshotResources.get(url) || cache.get(url);
511
+ export function lookupCacheResource(percy, snapshotResources, cache, url, width, rootUrl) {
512
+ let resource = snapshotResources.get(url);
513
+
514
+ // @percy/dom keys the resources it fabricates by a root-relative URL
515
+ // (/__serialized__/<uid>.<ext>) so no host or scheme is baked into the
516
+ // snapshot; the discovery browser requests the resolved absolute form.
517
+ // Match on the origin-less form (path + query), but only for requests from
518
+ // the snapshot's own origin: a root-relative href can resolve nowhere else,
519
+ // and an allowed cross-origin request must never be answered with the
520
+ // snapshot's bytes. Both snapshot lookups run before the shared cache so a
521
+ // snapshot's own provided bytes always win over whatever an earlier fetch
522
+ // of the same URL left cached.
523
+ if (!resource && rootUrl) {
524
+ try {
525
+ let {
526
+ origin,
527
+ pathname,
528
+ search
529
+ } = new URL(url);
530
+ if (origin === new URL(rootUrl).origin) {
531
+ resource = snapshotResources.get(pathname + search);
532
+ }
533
+ } catch (e) {
534
+ // url is not absolute -- nothing further to try
535
+ }
536
+ }
537
+ if (!resource) resource = cache.get(url);
513
538
  const disk = percy[DISK_SPILL_KEY];
514
539
  if (!resource && disk) {
515
540
  resource = disk.get(url);
@@ -680,7 +705,7 @@ export function createDiscoveryQueue(percy) {
680
705
  disableCache: snapshot.discovery.disableCache,
681
706
  allowedHostnames: snapshot.discovery.allowedHostnames,
682
707
  disallowedHostnames: snapshot.discovery.disallowedHostnames,
683
- getResource: (u, width = null) => lookupCacheResource(percy, snapshot.resources, cache, u, width),
708
+ getResource: (u, width = null) => lookupCacheResource(percy, snapshot.resources, cache, u, width, snapshot.url),
684
709
  saveResource: r => {
685
710
  var _percy$DISK_SPILL_KEY;
686
711
  const limitResources = process.env.LIMIT_SNAPSHOT_RESOURCES || false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.32.11",
3
+ "version": "1.32.12-beta.0",
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": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -46,12 +46,12 @@
46
46
  "dependencies": {
47
47
  "@grpc/grpc-js": "^1.14.3",
48
48
  "@grpc/proto-loader": "^0.8.0",
49
- "@percy/client": "1.32.11",
50
- "@percy/config": "1.32.11",
51
- "@percy/dom": "1.32.11",
52
- "@percy/logger": "1.32.11",
53
- "@percy/monitoring": "1.32.11",
54
- "@percy/webdriver-utils": "1.32.11",
49
+ "@percy/client": "1.32.12-beta.0",
50
+ "@percy/config": "1.32.12-beta.0",
51
+ "@percy/dom": "1.32.12-beta.0",
52
+ "@percy/logger": "1.32.12-beta.0",
53
+ "@percy/monitoring": "1.32.12-beta.0",
54
+ "@percy/webdriver-utils": "1.32.12-beta.0",
55
55
  "adm-zip": "^0.6.0",
56
56
  "busboy": "^1.6.0",
57
57
  "content-disposition": "^0.5.4",
@@ -67,8 +67,8 @@
67
67
  "yaml": "^2.4.1"
68
68
  },
69
69
  "optionalDependencies": {
70
- "@percy/cli-doctor": "1.32.11",
71
- "@percy/cli-pdf": "1.32.11"
70
+ "@percy/cli-doctor": "1.32.12-beta.0",
71
+ "@percy/cli-pdf": "1.32.12-beta.0"
72
72
  },
73
- "gitHead": "fe385ef03c5dbeb599a0152eab855c9ce9875071"
73
+ "gitHead": "e33cd43b4a422cc04243fa4ab1aeb42bd828a828"
74
74
  }