From 8a64ba6f4359c56d616d993e1799f6d4cce41cd9 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 1 Apr 2018 06:58:20 -0400 Subject: [PATCH] code review for 5c15f68 --- platform/webext/vapi-webrequest.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/webext/vapi-webrequest.js b/platform/webext/vapi-webrequest.js index 55c60b4bb..18d3dba95 100644 --- a/platform/webext/vapi-webrequest.js +++ b/platform/webext/vapi-webrequest.js @@ -136,7 +136,7 @@ vAPI.net.registerListeners = function() { }; // This is to work around Firefox's inability to redirect xmlhttprequest - // to data: URI. + // requests to data: URIs. let pseudoRedirector = { filters: new Map(), reDataURI: /^data:\w+\/\w+;base64,/, @@ -147,9 +147,9 @@ vAPI.net.registerListeners = function() { for ( let i = 0, n = s.length; i < n; i++ ) { this.dec[s.charCodeAt(i)] = i; } + return this.dec; }, start: function(requestId, redirectUrl) { - if ( this.dec === null ) { this.init(); } let match = this.reDataURI.exec(redirectUrl); if ( match === null ) { return redirectUrl; } let s = redirectUrl.slice(match[0].length).replace(/=*$/, ''); @@ -162,7 +162,7 @@ vAPI.net.registerListeners = function() { let pr = pseudoRedirector; let bufIn = pr.filters.get(this); if ( bufIn === undefined ) { return pr.disconnect(this); } - let dec = pr.dec; + let dec = pr.dec || pr.init(); let sizeIn = bufIn.length; let iIn = 0; let sizeOut = sizeIn * 6 >>> 3;