Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 22:26:09 +00:00
parent 3ba511a8f1
commit 1c4c64199f
175 changed files with 13227 additions and 15136 deletions

View file

@ -18,13 +18,11 @@ function responseArray(handler) {
if (typeof response[2] !== "string") {
if (!supportsArrayBuffer) {
throw new TypeError(
"Fake server response body should be a string, but was " +
typeof response[2]
`Fake server response body should be a string, but was ${typeof response[2]}`
);
} else if (!(response[2] instanceof ArrayBuffer)) {
throw new TypeError(
"Fake server response body should be a string or ArrayBuffer, but was " +
typeof response[2]
`Fake server response body should be a string or ArrayBuffer, but was ${typeof response[2]}`
);
}
}
@ -33,7 +31,15 @@ function responseArray(handler) {
}
function getDefaultWindowLocation() {
return { host: "localhost", protocol: "http" };
var winloc = {
hostname: "localhost",
port: process.env.PORT || 80,
protocol: "http:"
};
winloc.host =
winloc.hostname +
(String(winloc.port) === "80" ? "" : `:${winloc.port}`);
return winloc;
}
function getWindowLocation() {
@ -65,7 +71,8 @@ function matchOne(response, reqMethod, reqUrl) {
var matchUrl =
!url ||
url === reqUrl ||
(typeof url.test === "function" && url.test(reqUrl));
(typeof url.test === "function" && url.test(reqUrl)) ||
(typeof url === "function" && url(reqUrl) === true);
return matchMethod && matchUrl;
}
@ -73,12 +80,12 @@ function matchOne(response, reqMethod, reqUrl) {
function match(response, request) {
var wloc = getWindowLocation();
var rCurrLoc = new RegExp("^" + wloc.protocol + "//" + wloc.host);
var rCurrLoc = new RegExp(`^${wloc.protocol}//${wloc.host}/`);
var requestUrl = request.url;
if (!/^https?:\/\//.test(requestUrl) || rCurrLoc.test(requestUrl)) {
requestUrl = requestUrl.replace(rCurrLoc, "");
requestUrl = requestUrl.replace(rCurrLoc, "/");
}
if (matchOne(response, this.getHTTPMethod(request), requestUrl)) {
@ -136,7 +143,7 @@ var fakeServer = {
configure: function(config) {
var self = this;
var whitelist = {
var allowlist = {
autoRespond: true,
autoRespondAfter: true,
respondImmediately: true,
@ -149,7 +156,7 @@ var fakeServer = {
config = config || {};
Object.keys(config).forEach(function(setting) {
if (setting in whitelist) {
if (setting in allowlist) {
self[setting] = config[setting];
}
});
@ -228,6 +235,13 @@ var fakeServer = {
method = null;
}
// Escape port number to prevent "named" parameters in 'path-to-regexp' module
if (typeof url === "string" && url !== "" && /:[0-9]+\//.test(url)) {
var m = url.match(/^(https?:\/\/.*?):([0-9]+\/.*)$/);
// eslint-disable-next-line no-param-reassign
url = `${m[1]}\\:${m[2]}`;
}
push.call(this.responses, {
method: method,
url:

View file

@ -4,8 +4,8 @@ var inspect = require("util").inspect;
function log(response, request) {
var str;
str = "Request:\n" + inspect(request) + "\n\n";
str += "Response:\n" + inspect(response) + "\n\n";
str = `Request:\n${inspect(request)}\n\n`;
str += `Response:\n${inspect(response)}\n\n`;
/* istanbul ignore else: when this.logger is not a function, it can't be called */
if (typeof this.logger === "function") {