Skip to content

Commit

Permalink
Better handle Request argument in no-fetch-if
Browse files Browse the repository at this point in the history
As per internal feedback.
  • Loading branch information
gorhill committed Dec 24, 2020
1 parent 1c37e29 commit ab06a01
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,21 @@
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 ( const 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 ( const 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)
Expand Down

0 comments on commit ab06a01

Please sign in to comment.