arn-browser 0.1.16 → 0.1.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/package.json
CHANGED
|
@@ -90,11 +90,13 @@ async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl
|
|
|
90
90
|
mainUrl = url;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const viaProxy = proxyAgent ? " via Proxy" : "";
|
|
94
|
+
|
|
93
95
|
// Check if the response is cached
|
|
94
96
|
if (useCache) {
|
|
95
97
|
const cachedResponse = globalCache.get(mainUrl);
|
|
96
98
|
if (cachedResponse) {
|
|
97
|
-
if (logger === "info") console.log(`Serving from globalCache: ${mainUrl}`);
|
|
99
|
+
if (logger === "info") console.log(`Serving from globalCache${viaProxy}: ${mainUrl}`);
|
|
98
100
|
return cachedResponse;
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -121,9 +123,9 @@ async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl
|
|
|
121
123
|
headers: response.headers,
|
|
122
124
|
body: responseBody,
|
|
123
125
|
});
|
|
124
|
-
if (logger === "info") console.log(`Success (cached): ${mainUrl}`);
|
|
126
|
+
if (logger === "info") console.log(`Success (cached${viaProxy}): ${mainUrl}`);
|
|
125
127
|
} else {
|
|
126
|
-
if (logger === "info") console.log(`Success (not cached): ${mainUrl}`);
|
|
128
|
+
if (logger === "info") console.log(`Success (not cached${viaProxy}): ${mainUrl}`);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
return {
|
|
@@ -183,7 +185,15 @@ export async function pwRoute({
|
|
|
183
185
|
// --- SETUP: Merge Defaults for skipGotPatterns ---
|
|
184
186
|
// Always skip custom fetch for Cloudflare challenges (let browser handle it)
|
|
185
187
|
const defaultSkipPatterns = [];
|
|
186
|
-
|
|
188
|
+
// Normalize: if entry contains "://", extract hostname. Otherwise keep as-is (assumed to be a hostname).
|
|
189
|
+
const finalSkipHosts = new Set(
|
|
190
|
+
[...defaultSkipPatterns, ...skipGotPatterns].map((entry) => {
|
|
191
|
+
try {
|
|
192
|
+
if (entry.includes("://")) return new URL(entry).hostname;
|
|
193
|
+
} catch {}
|
|
194
|
+
return entry;
|
|
195
|
+
})
|
|
196
|
+
);
|
|
187
197
|
|
|
188
198
|
// Initialize ad blocking AdBlockEngine if enabled and not already loaded
|
|
189
199
|
if (blockAds && !AdBlockEngine) {
|
|
@@ -329,9 +339,12 @@ export async function pwRoute({
|
|
|
329
339
|
// ============================================================
|
|
330
340
|
// Group 6: Resource Interception (Custom Fetch/Cache)
|
|
331
341
|
// ============================================================
|
|
332
|
-
if (useGot && interceptedResourceTypes.includes(resourceType)) {
|
|
333
|
-
// Check against the
|
|
334
|
-
|
|
342
|
+
if (useGot && interceptedResourceTypes.includes(resourceType) && !url.startsWith("data:")) {
|
|
343
|
+
// Check against the normalized host list (defaults + user input)
|
|
344
|
+
let shouldSkipGot = false;
|
|
345
|
+
try {
|
|
346
|
+
shouldSkipGot = finalSkipHosts.has(new URL(url).hostname);
|
|
347
|
+
} catch {}
|
|
335
348
|
|
|
336
349
|
if (!shouldSkipGot) {
|
|
337
350
|
const requestHeaders = request.headers();
|
|
@@ -90,11 +90,13 @@ async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl
|
|
|
90
90
|
mainUrl = url;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const viaProxy = proxyAgent ? " via Proxy" : "";
|
|
94
|
+
|
|
93
95
|
// Check if the response is cached
|
|
94
96
|
if (useCache) {
|
|
95
97
|
const cachedResponse = globalCache.get(mainUrl);
|
|
96
98
|
if (cachedResponse) {
|
|
97
|
-
if (logger === "info") console.log(`Serving from globalCache: ${mainUrl}`);
|
|
99
|
+
if (logger === "info") console.log(`Serving from globalCache${viaProxy}: ${mainUrl}`);
|
|
98
100
|
return cachedResponse;
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -121,9 +123,9 @@ async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl
|
|
|
121
123
|
headers: response.headers,
|
|
122
124
|
body: responseBody,
|
|
123
125
|
});
|
|
124
|
-
if (logger === "info") console.log(`Success (cached): ${mainUrl}`);
|
|
126
|
+
if (logger === "info") console.log(`Success (cached${viaProxy}): ${mainUrl}`);
|
|
125
127
|
} else {
|
|
126
|
-
if (logger === "info") console.log(`Success (not cached): ${mainUrl}`);
|
|
128
|
+
if (logger === "info") console.log(`Success (not cached${viaProxy}): ${mainUrl}`);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
return {
|
|
@@ -180,7 +182,15 @@ export async function ppRoute({
|
|
|
180
182
|
// --- SETUP: Merge Defaults for skipGotPatterns ---
|
|
181
183
|
// Always skip custom fetch for Cloudflare challenges (let browser handle it)
|
|
182
184
|
const defaultSkipPatterns = [];
|
|
183
|
-
|
|
185
|
+
// Normalize: if entry contains "://", extract hostname. Otherwise keep as-is (assumed to be a hostname).
|
|
186
|
+
const finalSkipHosts = new Set(
|
|
187
|
+
[...defaultSkipPatterns, ...skipGotPatterns].map((entry) => {
|
|
188
|
+
try {
|
|
189
|
+
if (entry.includes("://")) return new URL(entry).hostname;
|
|
190
|
+
} catch {}
|
|
191
|
+
return entry;
|
|
192
|
+
})
|
|
193
|
+
);
|
|
184
194
|
|
|
185
195
|
// Initialize ad blocking AdBlockEngine if enabled and not already loaded
|
|
186
196
|
if (blockAds && !AdBlockEngine) {
|
|
@@ -332,9 +342,12 @@ export async function ppRoute({
|
|
|
332
342
|
// ============================================================
|
|
333
343
|
// Group 6: Resource Interception (Custom Fetch/Cache)
|
|
334
344
|
// ============================================================
|
|
335
|
-
if (useGot && interceptedResourceTypes.includes(resourceType)) {
|
|
336
|
-
// Check against the
|
|
337
|
-
|
|
345
|
+
if (useGot && interceptedResourceTypes.includes(resourceType) && !url.startsWith("data:")) {
|
|
346
|
+
// Check against the normalized host list (defaults + user input)
|
|
347
|
+
let shouldSkipGot = false;
|
|
348
|
+
try {
|
|
349
|
+
shouldSkipGot = finalSkipHosts.has(new URL(url).hostname);
|
|
350
|
+
} catch {}
|
|
338
351
|
|
|
339
352
|
if (!shouldSkipGot) {
|
|
340
353
|
const requestHeaders = request.headers();
|