@crouton-kit/capture 1.4.16 → 1.4.17

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/bin/capture CHANGED
@@ -6010,11 +6010,12 @@ function normalizeUrlForMatch(value) {
6010
6010
  try {
6011
6011
  const url = new URL(value);
6012
6012
  const path48 = url.pathname.replace(/\/+$/, "") || "/";
6013
+ const hostname = url.hostname.toLowerCase();
6014
+ const loopback = hostname === "localhost" || hostname === "127.0.0.1";
6015
+ const port = url.port || (url.protocol === "http:" ? "80" : url.protocol === "https:" ? "443" : "");
6013
6016
  return {
6014
6017
  full: `${url.origin}${path48}${url.search}${url.hash}`.toLowerCase(),
6015
- // `host` (not `hostname`): two local dev servers on the same loopback
6016
- // address but different ports must not register as a host match.
6017
- host: url.host.toLowerCase(),
6018
+ origin: `${url.protocol}//${loopback ? "loopback" : hostname}:${port}`,
6018
6019
  path: path48.toLowerCase()
6019
6020
  };
6020
6021
  } catch {
@@ -6026,14 +6027,11 @@ function scoreTabUrlMatch(tabUrl, requestedUrl) {
6026
6027
  const requested = normalizeUrlForMatch(requestedUrl);
6027
6028
  if (tab && requested) {
6028
6029
  if (tab.full === requested.full) return 100;
6029
- if (tab.host === requested.host && tab.path === requested.path) return 95;
6030
- if (tab.host === requested.host && tab.path.startsWith(requested.path)) return 90;
6031
- if (tab.host === requested.host && requested.path.startsWith(tab.path)) return 85;
6032
- if (tab.host === requested.host) return 70;
6033
- if (tab.full.includes(requested.full)) return 60;
6034
- if (tab.full.includes(requested.host)) return 50;
6035
- if (requested.full.includes(tab.full)) return 40;
6036
- return 0;
6030
+ if (tab.origin !== requested.origin) return 0;
6031
+ if (tab.path === requested.path) return 95;
6032
+ if (tab.path.startsWith(requested.path)) return 90;
6033
+ if (requested.path.startsWith(tab.path)) return 85;
6034
+ return 70;
6037
6035
  }
6038
6036
  const tabLower = tabUrl.toLowerCase();
6039
6037
  const requestedLower = requestedUrl.toLowerCase();
@@ -10561,7 +10559,7 @@ function validateHarAppendBatch(value, source) {
10561
10559
  return { entries, incompleteLifecycles };
10562
10560
  }
10563
10561
  function captureVersion() {
10564
- const version = "1.4.16";
10562
+ const version = "1.4.17";
10565
10563
  return typeof version === "string" && version.length > 0 ? version : "development";
10566
10564
  }
10567
10565
  function token() {
@@ -12663,7 +12661,7 @@ function wallTime(value) {
12663
12661
  }
12664
12662
  }
12665
12663
  function captureVersion2() {
12666
- const version = "1.4.16";
12664
+ const version = "1.4.17";
12667
12665
  return typeof version === "string" && version.length > 0 ? version : "development";
12668
12666
  }
12669
12667
  function deepFreeze(value) {
@@ -267359,7 +267357,7 @@ I/O contract: flags and positionals on input; one rendered prose block on stdout
267359
267357
  A CDP-enabled browser must be running; \`capture tab list\` is the probe, and \`capture tab launch\` starts one capture owns and reaps when nothing is (never hand-roll a detached browser \u2014 nothing reaps that). Capture never signals a browser it did not start, so attaching to your own with --port is unchanged. CDP_PORT / CDP_TARGET pin the browser + tab for target-selecting commands \u2014 precedence: explicit flag > active session > env. \`session start\` adopts only an explicit --target.`;
267360
267358
  }
267361
267359
  function printVersion() {
267362
- const declared = "1.4.16";
267360
+ const declared = "1.4.17";
267363
267361
  if (declared) {
267364
267362
  console.log(declared);
267365
267363
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crouton-kit/capture",
3
- "version": "1.4.16",
3
+ "version": "1.4.17",
4
4
  "description": "Browser automation and UI validation via CDP — session-based screenshots, HAR, a11y, click/type, and JS exec",
5
5
  "bin": {
6
6
  "capture": "./bin/capture"
@@ -149,15 +149,17 @@ export async function findUnambiguousPageTabInPorts(
149
149
  return candidates[0] ?? null;
150
150
  }
151
151
 
152
- function normalizeUrlForMatch(value: string): { full: string; host: string; path: string } | null {
152
+ function normalizeUrlForMatch(value: string): { full: string; origin: string; path: string } | null {
153
153
  try {
154
154
  const url = new URL(value);
155
155
  const path = url.pathname.replace(/\/+$/, '') || '/';
156
+ const hostname = url.hostname.toLowerCase();
157
+ // Electron may expose a localhost page when the caller uses its equivalent IPv4 loopback URL.
158
+ const loopback = hostname === 'localhost' || hostname === '127.0.0.1';
159
+ const port = url.port || (url.protocol === 'http:' ? '80' : url.protocol === 'https:' ? '443' : '');
156
160
  return {
157
161
  full: `${url.origin}${path}${url.search}${url.hash}`.toLowerCase(),
158
- // `host` (not `hostname`): two local dev servers on the same loopback
159
- // address but different ports must not register as a host match.
160
- host: url.host.toLowerCase(),
162
+ origin: `${url.protocol}//${loopback ? 'loopback' : hostname}:${port}`,
161
163
  path: path.toLowerCase(),
162
164
  };
163
165
  } catch {
@@ -171,14 +173,11 @@ export function scoreTabUrlMatch(tabUrl: string, requestedUrl: string): number {
171
173
 
172
174
  if (tab && requested) {
173
175
  if (tab.full === requested.full) return 100;
174
- if (tab.host === requested.host && tab.path === requested.path) return 95;
175
- if (tab.host === requested.host && tab.path.startsWith(requested.path)) return 90;
176
- if (tab.host === requested.host && requested.path.startsWith(tab.path)) return 85;
177
- if (tab.host === requested.host) return 70;
178
- if (tab.full.includes(requested.full)) return 60;
179
- if (tab.full.includes(requested.host)) return 50;
180
- if (requested.full.includes(tab.full)) return 40;
181
- return 0;
176
+ if (tab.origin !== requested.origin) return 0;
177
+ if (tab.path === requested.path) return 95;
178
+ if (tab.path.startsWith(requested.path)) return 90;
179
+ if (requested.path.startsWith(tab.path)) return 85;
180
+ return 70;
182
181
  }
183
182
 
184
183
  const tabLower = tabUrl.toLowerCase();