New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

woodland

Package Overview
Dependencies
Maintainers
1
Versions
352
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

woodland - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

93

lib/utility.js
"use strict";
const coerce = require("tiny-coerce"),
url = require("url");
function trim (obj) {

@@ -22,94 +19,6 @@ return obj.replace(/^(\s+|\t+|\n+)|(\s+|\t+|\n+)$/g, "");

function iterate (obj, fn) {
if (obj instanceof Object) {
Object.keys(obj).forEach(i => {
fn.call(obj, obj[i], i);
});
} else {
obj.forEach(fn);
}
}
function queryString (qstring = "") {
let obj = {},
aresult = qstring.split("?"),
result;
if (aresult.length > 1) {
aresult.shift();
}
result = aresult.join("?");
result.split("&").forEach(prop => {
let aitem = prop.replace(/\+/g, " ").split("="),
item;
if (aitem.length > 2) {
item = [aitem.shift(), aitem.join("=")];
} else {
item = aitem;
}
if (isEmpty(item[0])) {
return;
}
if (item[1] === undefined) {
item[1] = "";
} else {
item[1] = coerce(decodeURIComponent(item[1]));
}
if (obj[item[0]] === undefined) {
obj[item[0]] = item[1];
} else if (obj[item[0]] instanceof Array === false) {
obj[item[0]] = [obj[item[0]]];
obj[item[0]].push(item[1]);
} else {
obj[item[0]].push(item[1]);
}
});
return obj;
}
function parse (uri) {
let luri = uri,
idxAscii, idxQ, parsed;
if (luri === undefined || luri === null) {
luri = "";
} else {
idxAscii = luri.indexOf("%3F");
idxQ = luri.indexOf("?");
switch (true) {
case idxQ === -1 && idxAscii > -1:
case idxAscii < idxQ:
luri = luri.replace("%3F", "?");
break;
default:
void 0;
}
}
parsed = url.parse(luri);
parsed.pathname = parsed.pathname.replace(/%20/g, " ");
parsed.path = parsed.pathname + (parsed.search || "");
parsed.query = parsed.search ? queryString(parsed.search) : {};
iterate(parsed, (v, k) => {
if (v === null) {
parsed[k] = "";
}
});
return parsed;
}
module.exports = {
escape: escape,
getArity: getArity,
isEmpty: isEmpty,
parse: parse
isEmpty: isEmpty
};

9

lib/woodland.js

@@ -8,2 +8,3 @@ "use strict";

http = require("http"),
parse = require("tiny-parse"),
mmh3 = require("murmurhash3js").x86.hash32,

@@ -77,3 +78,3 @@ utility = require(path.join(__dirname, "utility.js")),

decorate (req, res) {
let parsed = utility.parse(this.url(req)),
let parsed = parse(this.url(req)),
remotes = req.headers["x-forwarded-for"] ? req.headers["x-forwarded-for"].split(/\s*,\s*/g) : [req.connection.remoteAddress];

@@ -129,5 +130,5 @@

method = head.test(req.method) ? "GET" : req.method,
last, middleware, next, result;
middleware, result;
last = err => {
let last = err => {
let allowed, errorCode, status;

@@ -153,3 +154,3 @@

next = err => {
let next = err => {
process.nextTick(() => {

@@ -156,0 +157,0 @@ let arity, iter;

{
"name": "woodland",
"version": "1.1.0",
"version": "1.1.1",
"description": "Lightweight HTTP/HTTPS router with virtual hosts",

@@ -32,5 +32,5 @@ "main": "index.js",

"murmurhash3js": "~3.0.1",
"tiny-coerce": "~1.0.1",
"tiny-defer": "~1.0.4",
"tiny-lru": "~1.1.0"
"tiny-lru": "~1.1.0",
"tiny-parse": "^1.0.1"
},

@@ -37,0 +37,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc