mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Fix regression in prevent-fetch scriptlet
Related feedback: https://github.com/uBlockOrigin/uAssets/issues/30954#issuecomment-3589375849
This commit is contained in:
parent
95aca83289
commit
be78200c2f
1 changed files with 25 additions and 24 deletions
|
|
@ -75,33 +75,34 @@ function preventFetchFn(
|
|||
responseProps.type = { value: responseType };
|
||||
}
|
||||
}
|
||||
const fetchProps = (src, out) => {
|
||||
if ( typeof src !== 'object' || src === null ) { return; }
|
||||
const props = [
|
||||
'body', 'cache', 'credentials', 'duplex', 'headers',
|
||||
'integrity', 'keepalive', 'method', 'mode', 'priority',
|
||||
'redirect', 'referrer', 'referrerPolicy', 'signal',
|
||||
];
|
||||
for ( const prop of props ) {
|
||||
if ( src[prop] === undefined ) { continue; }
|
||||
out[prop] = src[prop];
|
||||
}
|
||||
};
|
||||
const fetchDetails = args => {
|
||||
const out = {};
|
||||
if ( args[0] instanceof self.Request ) {
|
||||
out.url = `${args[0].url}`;
|
||||
fetchProps(args[0], out);
|
||||
} else {
|
||||
out.url = `${args[0]}`;
|
||||
}
|
||||
fetchProps(args[1], out);
|
||||
return out;
|
||||
};
|
||||
proxyApplyFn('fetch', function fetch(context) {
|
||||
const { callArgs } = context;
|
||||
const details = (( ) => {
|
||||
const fetchProps = (src, out) => {
|
||||
if ( typeof src !== 'object' || src === null ) { return; }
|
||||
const props = [
|
||||
'body', 'cache', 'credentials', 'duplex', 'headers',
|
||||
'integrity', 'keepalive', 'method', 'mode', 'priority',
|
||||
'redirect', 'referrer', 'referrerPolicy', 'signal',
|
||||
];
|
||||
for ( const prop of props ) {
|
||||
if ( src[prop] === undefined ) { continue; }
|
||||
out[prop] = src[prop];
|
||||
}
|
||||
};
|
||||
const out = {};
|
||||
if ( callArgs[0] instanceof self.Request ) {
|
||||
out.url = `${callArgs[0].url}`;
|
||||
fetchProps(callArgs[0], out);
|
||||
} else {
|
||||
out.url = `${callArgs[0]}`;
|
||||
}
|
||||
fetchProps(callArgs[1], out);
|
||||
return out;
|
||||
})();
|
||||
const details = fetchDetails(callArgs);
|
||||
if ( safe.logLevel > 1 || propsToMatch === '' && responseBody === '' ) {
|
||||
const out = Array.from(details).map(a => `${a[0]}:${a[1]}`);
|
||||
const out = Array.from(Object.entries(details)).map(a => `${a[0]}:${a[1]}`);
|
||||
safe.uboLog(logPrefix, `Called: ${out.join('\n')}`);
|
||||
}
|
||||
if ( propsToMatch === '' && responseBody === '' ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue