Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (typeof connectOverride === 'object') {
this._connectOverride = connectOverride;
} else {
this._connectOverride = undefined;
}
return this;
};
Request.prototype.trustLocalhost = function(toggle) {
this._trustLocalhost = toggle === undefined ? true : toggle;
return this;
};
// generate HTTP verb methods
if (!methods.includes('del')) {
// create a copy so we don't cause conflicts with
// other packages using the methods package and
// npm 3.x
methods = methods.slice(0);
methods.push('del');
}
methods.forEach(method => {
const name = method;
method = method === 'del' ? 'delete' : method;
method = method.toUpperCase();
request[name] = (url, data, fn) => {
const req = request(method, url);
if (typeof data === 'function') {
fn = data;
methodNames.forEach(name => {
let preHandleName = name.replace(methodNameReg, "$1-$2").split("-");
let method = preHandleName[0];
if (methods.includes(method)) {
let path = preHandleName[1].replace(/^./, function (match) {
return match.toLowerCase();
});
if (this.__router[method] && path) {
if (path == "api") {
this.__router[method]("/api*", this.__proto__[name].bind(this));
} else {
this.__router[method](`/${path}`, this.__proto__[name].bind(this));
}
}
}
});
}
const isMethod = method => methods.includes(method);
const isFunction = func => typeof func === 'function';