Comparing version 16.1.0 to 16.1.1
"use strict"; | ||
const levels = { | ||
const all = "*", | ||
delimiter = "|", | ||
levels = { | ||
emerg: 0, | ||
@@ -29,4 +31,6 @@ alert: 1, | ||
module.exports = { | ||
all, | ||
delimiter, | ||
levels, | ||
months | ||
}; |
@@ -8,6 +8,18 @@ "use strict"; | ||
coerce = require("tiny-coerce"), | ||
mime = require(path.join(__dirname, "mime.js")), | ||
all = "*", | ||
delimiter = "|"; | ||
html = fs.readFileSync(path.join(__dirname, "..", "tpl", "autoindex.html"), {encoding: "utf8"}), | ||
valid = Object.entries(require("mime-db")).filter(i => "extensions" in i[1]), | ||
extensions = valid.reduce((a, v) => { | ||
const result = Object.assign({type: v[0]}, v[1]); | ||
for (const key of result.extensions) { | ||
a[`.${key}`] = result; | ||
} | ||
return a; | ||
}, {}); | ||
function autoindex (title = "", files = []) { // eslint-disable-line no-unused-vars | ||
return eval("`" + html + "`"); // eslint-disable-line no-eval | ||
} | ||
function clone (arg) { | ||
@@ -31,2 +43,8 @@ return JSON.parse(JSON.stringify(arg)); | ||
function mime (arg = "") { | ||
const ext = path.extname(arg); | ||
return ext in extensions ? extensions[ext].type : "application/octet-stream"; | ||
} | ||
function ms (arg = 0, digits = 3) { | ||
@@ -216,5 +234,4 @@ return `${Number(arg / 1e6).toFixed(digits)} ms`; | ||
module.exports = { | ||
all, | ||
autoindex, | ||
clone, | ||
delimiter, | ||
last, | ||
@@ -221,0 +238,0 @@ ms, |
@@ -11,5 +11,5 @@ "use strict"; | ||
lru = require("tiny-lru"), | ||
aindex = require(path.join(__dirname, "autoindex.js")), | ||
{levels, months} = require(path.join(__dirname, "constants.js")), | ||
{all, clone, delimiter, last, ms, next, pad, params, parse, partial, pipeable, reduce, stream, timeOffset, writeHead} = require(path.join(__dirname, "utility.js")); | ||
{all, delimiter, levels, months} = require(path.join(__dirname, "constants.js")), | ||
{clone, last, ms, next, pad, params, parse, partial, pipeable, reduce, stream, timeOffset, writeHead} = require(path.join(__dirname, "utility.js")), | ||
aindex = require(path.join(__dirname, "utility.js")).autoindex; | ||
@@ -16,0 +16,0 @@ class Woodland extends EventEmitter { |
{ | ||
"name": "woodland", | ||
"version": "16.1.0", | ||
"version": "16.1.1", | ||
"description": "Lightweight HTTP router with automatic headers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -172,15 +172,13 @@ <img src="https://avoidwork.github.io/woodland/logo.svg" width="108" /> | ||
```console | ||
---------------|---------|----------|---------|---------|--------------------------------------------------------------------------------- | ||
---------------|---------|----------|---------|---------|------------------------------------------------------------------------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
---------------|---------|----------|---------|---------|--------------------------------------------------------------------------------- | ||
All files | 91.97 | 72.7 | 95.38 | 92.23 | | ||
woodland | 100 | 100 | 100 | 100 | | ||
index.js | 100 | 100 | 100 | 100 | | ||
woodland/lib | 91.85 | 72.7 | 95.31 | 92.11 | | ||
autoindex.js | 100 | 0 | 100 | 100 | 7 | ||
constants.js | 100 | 100 | 100 | 100 | | ||
mime.js | 100 | 33.33 | 100 | 100 | 15-18 | ||
utility.js | 91.89 | 73.39 | 100 | 91.82 | 22,143-145,160-161,163,167,185 | ||
woodland.js | 91.27 | 73.44 | 92.86 | 91.7 | 141,153-154,172-173,228-229,239,270-274,289,296,406,420,429-430,437,443,473,477 | ||
---------------|---------|----------|---------|---------|--------------------------------------------------------------------------------- | ||
---------------|---------|----------|---------|---------|------------------------------------------------------------------------------------- | ||
All files | 91.67 | 72.61 | 95.38 | 91.92 | | ||
woodland | 100 | 100 | 100 | 100 | | ||
index.js | 100 | 100 | 100 | 100 | | ||
woodland/lib | 91.54 | 72.61 | 95.31 | 91.79 | | ||
constants.js | 100 | 100 | 100 | 100 | | ||
utility.js | 92.44 | 71.32 | 100 | 92.31 | 34,161-163,178-179,181,185,203 | ||
woodland.js | 91.01 | 73.28 | 92.86 | 91.42 | 142,154-155,173-174,229-230,235,244,275-279,294,301,411,425,434-435,442,448,478,482 | ||
---------------|---------|----------|---------|---------|------------------------------------------------------------------------------------- | ||
``` | ||
@@ -187,0 +185,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
141460
7
11
681
189