Skip to content
Permalink
Browse files
Better handle Request argument in no-fetch-if
As per internal feedback.

Related commit:
- gorhill/uBlock@ab06a01

Co-authored-by: Raymond Hill <rhill@raymondhill.net>
  • Loading branch information
JustOff and gorhill committed Jan 25, 2021
1 parent 3d5ad9f commit 36479283bf089e5858c078637a5f896e3eaa490a
Showing with 14 additions and 9 deletions.
  1. +14 −9 assets/resources/resources.txt
@@ -2129,16 +2129,21 @@ no-fetch-if.js application/javascript
apply: function(target, thisArg, args) {
let proceed = true;
try {
const url = args[0] instanceof self.Request
? args[0].url
: args[0];
const props = new Map([ [ 'url', url ] ]);
const init = args[1];
if ( init instanceof Object ) {
for ( let prop in init ) {
if ( init.hasOwnProperty(prop) === false ) { continue; }
props.set( prop, init[prop]);
let details;
if ( args[0] instanceof self.Request ) {
details = args[0];
} else {
details = Object.assign({ url: args[0] }, args[1]);
}
const props = new Map();
for ( let prop in details ) {
let v = details[prop];
if ( typeof v !== 'string' ) {
try { v = JSON.stringify(v); }
catch(ex) { }
}
if ( typeof v !== 'string' ) { continue; }
props.set(prop, v);
}
if ( log !== undefined ) {
const out = Array.from(props)

0 comments on commit 3647928

Please sign in to comment.