Skip to content

Commit

Permalink
Add stackToMatch vararg to json-prune-related scriptlets
Browse files Browse the repository at this point in the history
As per discussion with filter list maintainers.
  • Loading branch information
gorhill committed Oct 5, 2023
1 parent 7416340 commit 6b211f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,7 @@ function jsonPruneFetchResponse(
const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, });
const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { });
const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url');
const stackNeedle = safe.initPattern(extraArgs.stackToMatch || '', { canNegate: true });
const applyHandler = function(target, thisArg, args) {
const fetchPromise = Reflect.apply(target, thisArg, args);
if ( logLevel === true ) {
Expand Down Expand Up @@ -1289,7 +1290,7 @@ function jsonPruneFetchResponse(
objBefore,
rawPrunePaths,
rawNeedlePaths,
{ matchAll: true },
stackNeedle,
extraArgs
);
if ( typeof objAfter !== 'object' ) { return responseBefore; }
Expand Down Expand Up @@ -1342,6 +1343,7 @@ function jsonPruneXhrResponse(
const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, });
const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { });
const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url');
const stackNeedle = safe.initPattern(extraArgs.stackToMatch || '', { canNegate: true });
self.XMLHttpRequest = class extends self.XMLHttpRequest {
open(method, url, ...args) {
const xhrDetails = { method, url };
Expand Down Expand Up @@ -1389,7 +1391,7 @@ function jsonPruneXhrResponse(
objBefore,
rawPrunePaths,
rawNeedlePaths,
{ matchAll: true },
stackNeedle,
extraArgs
);
let outerResponse;
Expand Down

0 comments on commit 6b211f6

Please sign in to comment.