@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 +12 -14
- package/package.json +1 -1
- package/src/cdp/targets.ts +11 -12
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
|
-
|
|
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.
|
|
6030
|
-
if (tab.
|
|
6031
|
-
if (tab.
|
|
6032
|
-
if (tab.
|
|
6033
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
267360
|
+
const declared = "1.4.17";
|
|
267363
267361
|
if (declared) {
|
|
267364
267362
|
console.log(declared);
|
|
267365
267363
|
return;
|
package/package.json
CHANGED
package/src/cdp/targets.ts
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
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.
|
|
175
|
-
if (tab.
|
|
176
|
-
if (tab.
|
|
177
|
-
if (tab.
|
|
178
|
-
|
|
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();
|