Skip to content

Commit

Permalink
fix(style): es3-compatible interceptor.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tehhowch committed Sep 14, 2023
1 parent 49ff87d commit 706893e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"singleQuote": true
"singleQuote": true,
"overrides": [
{
"files": "lib/interceptor.js",
"options": {
"trailingComma": "none"
}
}
]
}
20 changes: 10 additions & 10 deletions lib/interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var interceptor = {
window[NAMESPACE] = {
interceptorDisabled: false,
excludedUrls: [],
requests: [],
requests: []
};

// Some browsers don't support FormData.entries(), so we polyfill that (sigh)
Expand Down Expand Up @@ -62,7 +62,7 @@ var interceptor = {
method: 'GET',
requestHeaders: {},
requestBody: undefined,
url: '',
url: ''
};
var input = arguments[0];
var init = arguments[1];
Expand Down Expand Up @@ -104,9 +104,9 @@ var interceptor = {
requestBody: results[0],
body: results[1],
statusCode: clonedResponse.status,
headers: parseHeaders(clonedResponse.headers),
headers: parseHeaders(clonedResponse.headers)
});
},
}
);

// Forward the original response to the application on the current tick.
Expand Down Expand Up @@ -142,7 +142,7 @@ var interceptor = {
method: this.lastMethod.toUpperCase(),
requestHeaders: this.lastRequestHeader || {},
requestBody: parsePayload(arguments[0]),
url: this.lastURL.toString(),
url: this.lastURL.toString()
};
addPendingRequest(this.lastReq);
originalSend.apply(this, arguments);
Expand All @@ -168,7 +168,7 @@ var interceptor = {
function parseBody(xhr, request) {
if (xhr.responseType === 'arraybuffer') {
return {
body: new TextDecoder().decode(xhr.response),
body: new TextDecoder().decode(xhr.response)
};
} else if (xhr.responseType === 'blob') {
// Read the response like a file.
Expand All @@ -181,7 +181,7 @@ var interceptor = {
}
// IE9 comp: need xhr.responseText
return {
body: xhr.response || xhr.responseText,
body: xhr.response || xhr.responseText
};
}

Expand Down Expand Up @@ -266,7 +266,7 @@ var interceptor = {
return JSON.parse(rawData);
} catch (e) {
throw new Error(
PKG_PREFIX + 'Could not parse sessionStorage data: ' + e.message,
PKG_PREFIX + 'Could not parse sessionStorage data: ' + e.message
);
}
}
Expand Down Expand Up @@ -355,7 +355,7 @@ var interceptor = {
parsed = JSON.parse(rawData);
} catch (e) {
throw new Error(
PKG_PREFIX + 'Could not parse sessionStorage data: ' + e.message,
PKG_PREFIX + 'Could not parse sessionStorage data: ' + e.message
);
}
}
Expand Down Expand Up @@ -412,7 +412,7 @@ var interceptor = {
if (typeof allRequests[idx].__fulfilled === 'undefined') return true;
}
return false;
},
}
};

module.exports = interceptor;

0 comments on commit 706893e

Please sign in to comment.