Add `stackToMatch` vararg to json-prune-related scriptlets

As per discussion with filter list maintainers.
This commit is contained in:
Raymond Hill 2023-10-05 11:24:35 -04:00
parent 7416340144
commit 6b211f622c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 2 deletions

View File

@ -1257,6 +1257,7 @@ function jsonPruneFetchResponse(
const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, }); const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, });
const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { }); const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { });
const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url'); const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url');
const stackNeedle = safe.initPattern(extraArgs.stackToMatch || '', { canNegate: true });
const applyHandler = function(target, thisArg, args) { const applyHandler = function(target, thisArg, args) {
const fetchPromise = Reflect.apply(target, thisArg, args); const fetchPromise = Reflect.apply(target, thisArg, args);
if ( logLevel === true ) { if ( logLevel === true ) {
@ -1289,7 +1290,7 @@ function jsonPruneFetchResponse(
objBefore, objBefore,
rawPrunePaths, rawPrunePaths,
rawNeedlePaths, rawNeedlePaths,
{ matchAll: true }, stackNeedle,
extraArgs extraArgs
); );
if ( typeof objAfter !== 'object' ) { return responseBefore; } if ( typeof objAfter !== 'object' ) { return responseBefore; }
@ -1342,6 +1343,7 @@ function jsonPruneXhrResponse(
const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, }); const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, });
const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { }); const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { });
const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url'); const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url');
const stackNeedle = safe.initPattern(extraArgs.stackToMatch || '', { canNegate: true });
self.XMLHttpRequest = class extends self.XMLHttpRequest { self.XMLHttpRequest = class extends self.XMLHttpRequest {
open(method, url, ...args) { open(method, url, ...args) {
const xhrDetails = { method, url }; const xhrDetails = { method, url };
@ -1389,7 +1391,7 @@ function jsonPruneXhrResponse(
objBefore, objBefore,
rawPrunePaths, rawPrunePaths,
rawNeedlePaths, rawNeedlePaths,
{ matchAll: true }, stackNeedle,
extraArgs extraArgs
); );
let outerResponse; let outerResponse;