diff --git a/hviews.txt b/hviews.txt
deleted file mode 100644
index 573541a..0000000
--- a/hviews.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/index.html b/index.html
index 455e91e..67e7b2f 100644
--- a/index.html
+++ b/index.html
@@ -1,7 +1,7 @@
-
License: BSD-3
diff --git a/licenses/pretty-bytes.txt b/licenses/pretty-bytes.txt
deleted file mode 100644
index e7af2f7..0000000
--- a/licenses/pretty-bytes.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) Sindre Sorhus (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/pretty-bytes/index.d.ts b/node_modules/pretty-bytes/index.d.ts
deleted file mode 100755
index 9a64626..0000000
--- a/node_modules/pretty-bytes/index.d.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-declare namespace prettyBytes {
- interface Options {
- /**
- Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
-
- @default false
- */
- readonly signed?: boolean;
-
- /**
- - If `false`: Output won't be localized.
- - If `true`: Localize the output using the system/browser locale.
- - If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
-
- __Note:__ Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime.
-
- @default false
- */
- readonly locale?: boolean | string;
-
- /**
- Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
-
- @default false
-
- ```
- import prettyBytes = require('pretty-bytes');
-
- prettyBytes(1337, {bits: true});
- //=> '1.34 kbit'
- ```
- */
- readonly bits?: boolean;
- }
-}
-
-/**
-Convert bytes to a human readable string: `1337` → `1.34 kB`.
-
-@param number - The number to format.
-
-@example
-```
-import prettyBytes = require('pretty-bytes');
-
-prettyBytes(1337);
-//=> '1.34 kB'
-
-prettyBytes(100);
-//=> '100 B'
-
-// Display file size differences
-prettyBytes(42, {signed: true});
-//=> '+42 B'
-
-// Localized output using German locale
-prettyBytes(1337, {locale: 'de'});
-//=> '1,34 kB'
-```
-*/
-declare function prettyBytes(
- number: number,
- options?: prettyBytes.Options
-): string;
-
-export = prettyBytes;
diff --git a/node_modules/pretty-bytes/index.js b/node_modules/pretty-bytes/index.js
deleted file mode 100755
index b7a0bac..0000000
--- a/node_modules/pretty-bytes/index.js
+++ /dev/null
@@ -1,76 +0,0 @@
-'use strict';
-
-const BYTE_UNITS = [
- 'B',
- 'kB',
- 'MB',
- 'GB',
- 'TB',
- 'PB',
- 'EB',
- 'ZB',
- 'YB'
-];
-
-const BIT_UNITS = [
- 'b',
- 'kbit',
- 'Mbit',
- 'Gbit',
- 'Tbit',
- 'Pbit',
- 'Ebit',
- 'Zbit',
- 'Ybit'
-];
-
-/*
-Formats the given number using `Number#toLocaleString`.
-- If locale is a string, the value is expected to be a locale-key (for example: `de`).
-- If locale is true, the system default locale is used for translation.
-- If no value for locale is specified, the number is returned unmodified.
-*/
-const toLocaleString = (number, locale) => {
- let result = number;
- if (typeof locale === 'string') {
- result = number.toLocaleString(locale);
- } else if (locale === true) {
- result = number.toLocaleString();
- }
-
- return result;
-};
-
-module.exports = (number, options) => {
- if (!Number.isFinite(number)) {
- throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
- }
-
- options = Object.assign({bits: false}, options);
- const UNITS = options.bits ? BIT_UNITS : BYTE_UNITS;
-
- if (options.signed && number === 0) {
- return ' 0 ' + UNITS[0];
- }
-
- const isNegative = number < 0;
- const prefix = isNegative ? '-' : (options.signed ? '+' : '');
-
- if (isNegative) {
- number = -number;
- }
-
- if (number < 1) {
- const numberString = toLocaleString(number, options.locale);
- return prefix + numberString + ' ' + UNITS[0];
- }
-
- const exponent = Math.min(Math.floor(Math.log10(number) / 3), UNITS.length - 1);
- // eslint-disable-next-line unicorn/prefer-exponentiation-operator
- number = Number((number / Math.pow(1000, exponent)).toPrecision(3));
- const numberString = toLocaleString(number, options.locale);
-
- const unit = UNITS[exponent];
-
- return prefix + numberString + ' ' + unit;
-};
diff --git a/node_modules/pretty-bytes/license b/node_modules/pretty-bytes/license
deleted file mode 100755
index e7af2f7..0000000
--- a/node_modules/pretty-bytes/license
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) Sindre Sorhus (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/pretty-bytes/package.json b/node_modules/pretty-bytes/package.json
deleted file mode 100755
index 9f4af15..0000000
--- a/node_modules/pretty-bytes/package.json
+++ /dev/null
@@ -1,76 +0,0 @@
-{
- "_from": "pretty-bytes@^5.3.0",
- "_id": "pretty-bytes@5.3.0",
- "_inBundle": false,
- "_integrity": "sha512-hjGrh+P926p4R4WbaB6OckyRtO0F0/lQBiT+0gnxjV+5kjPBrfVBFCsCLbMqVQeydvIoouYTCmmEURiH3R1Bdg==",
- "_location": "/pretty-bytes",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "pretty-bytes@^5.3.0",
- "name": "pretty-bytes",
- "escapedName": "pretty-bytes",
- "rawSpec": "^5.3.0",
- "saveSpec": null,
- "fetchSpec": "^5.3.0"
- },
- "_requiredBy": [
- "/autocannon"
- ],
- "_resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz",
- "_shasum": "f2849e27db79fb4d6cfe24764fc4134f165989f2",
- "_spec": "pretty-bytes@^5.3.0",
- "_where": "/media/serveradmin/Server/developement/node_modules/autocannon",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "bugs": {
- "url": "https://github.com/sindresorhus/pretty-bytes/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Convert bytes to a human readable string: 1337 → 1.34 kB",
- "devDependencies": {
- "ava": "^1.4.1",
- "full-icu": "^1.2.1",
- "tsd": "^0.7.2",
- "xo": "^0.24.0"
- },
- "engines": {
- "node": ">=6"
- },
- "files": [
- "index.js",
- "index.d.ts"
- ],
- "homepage": "https://github.com/sindresorhus/pretty-bytes#readme",
- "keywords": [
- "pretty",
- "bytes",
- "byte",
- "filesize",
- "size",
- "file",
- "human",
- "humanized",
- "readable",
- "si",
- "data",
- "locale",
- "localization",
- "localized"
- ],
- "license": "MIT",
- "name": "pretty-bytes",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/sindresorhus/pretty-bytes.git"
- },
- "scripts": {
- "test": "xo && NODE_ICU_DATA=node_modules/full-icu ava && tsd"
- },
- "version": "5.3.0"
-}
diff --git a/node_modules/pretty-bytes/readme.md b/node_modules/pretty-bytes/readme.md
deleted file mode 100755
index 0f77498..0000000
--- a/node_modules/pretty-bytes/readme.md
+++ /dev/null
@@ -1,89 +0,0 @@
-# pretty-bytes [![Build Status](https://travis-ci.org/sindresorhus/pretty-bytes.svg?branch=master)](https://travis-ci.org/sindresorhus/pretty-bytes)
-
-> Convert bytes to a human readable string: `1337` → `1.34 kB`
-
-Useful for displaying file sizes for humans.
-
-*Note that it uses base-10 (e.g. kilobyte).
-[Read about the difference between kilobyte and kibibyte.](https://web.archive.org/web/20150324153922/https://pacoup.com/2009/05/26/kb-kb-kib-whats-up-with-that/)*
-
-
-## Install
-
-```
-$ npm install pretty-bytes
-```
-
-
-## Usage
-
-```js
-const prettyBytes = require('pretty-bytes');
-
-prettyBytes(1337);
-//=> '1.34 kB'
-
-prettyBytes(100);
-//=> '100 B'
-
-// Display with units of bits
-prettyBytes(1337, {bits: true});
-//=> '1.34 kbit'
-
-// Display file size differences
-prettyBytes(42, {signed: true});
-//=> '+42 B'
-
-// Localized output using German locale
-prettyBytes(1337, {locale: 'de'});
-//=> '1,34 kB'
-```
-
-
-## API
-
-### prettyBytes(number, [options])
-
-#### number
-
-Type: `number`
-
-The number to format.
-
-#### options
-
-Type: `object`
-
-##### signed
-
-Type: `boolean`
-Default: `false`
-
-Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
-
-##### bits
-
-Type: `boolean`
-Default: `false`
-
-Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
-
-##### locale
-
-Type: `boolean` `string`
-Default: `false` *(No localization)*
-
-- If `true`: Localize the output using the system/browser locale.
-- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
-
-**Note:** Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime.
-
-
-## Related
-
-- [pretty-bytes-cli](https://github.com/sindresorhus/pretty-bytes-cli) - CLI for this module
-
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/svr.js b/svr.js
index 37e5a74..2d81ef5 100644
--- a/svr.js
+++ b/svr.js
@@ -81,7 +81,7 @@ function deleteFolderRecursive(path) {
}
var os = require("os");
-var version = "3.10.0";
+var version = "3.10.1";
var singlethreaded = false;
if (process.versions) process.versions.svrjs = version; // Inject SVR.JS into process.versions
@@ -435,14 +435,6 @@ try {
_errored: err
};
}
-var prettyBytes = undefined;
-try {
- prettyBytes = require("pretty-bytes");
-} catch (err) {
- prettyBytes = {
- _errored: err
- };
-}
var http2 = {};
try {
http2 = require("http2");
@@ -508,31 +500,15 @@ if (!fs.existsSync(__dirname + "/temp")) fs.mkdirSync(__dirname + "/temp");
var modFiles = fs.readdirSync(__dirname + "/mods").sort();
var modInfos = [];
-function sizify(x) {
- try {
- if (prettyBytes._errored) throw prettyBytes._errored;
- return prettyBytes(parseInt(x), {
- minimumFractionDigits: 0,
- maximumFractionDigits: 2
- }).replace(/ /g, "").replace(/B/ig, "").replace(/k/g, "K");
- } catch (err) {
- if (x < 1000) return x.toString();
- if (x < 10000) return (Math.round(x / 10) / 100).toString() + "K";
- if (x < 100000) return (Math.round(x / 100) / 10).toString() + "K";
- if (x < 1000000) return (Math.round(x / 1000)).toString() + "K";
- if (x < 10000000) return (Math.round(x / 10000) / 100).toString() + "M";
- if (x < 100000000) return (Math.round(x / 100000) / 10).toString() + "M";
- if (x < 1000000000) return (Math.round(x / 1000000)).toString() + "M";
- if (x < 10000000000) return (Math.round(x / 10000000) / 100).toString() + "G";
- if (x < 100000000000) return (Math.round(x / 100000000) / 10).toString() + "G";
- if (x < 1000000000000) return (Math.round(x / 1000000000)).toString() + "G";
- if (x < 10000000000000) return (Math.round(x / 10000000000) / 100).toString() + "T";
- if (x < 100000000000000) return (Math.round(x / 100000000000) / 10).toString() + "T";
- if (x < 1000000000000000) return (Math.round(x / 1000000000000)).toString() + "T";
- if (x < 10000000000000000) return (Math.round(x / 10000000000000) / 100).toString() + "P";
- if (x < 100000000000000000) return (Math.round(x / 100000000000000) / 10).toString() + "P";
- return (Math.round(x / 1000000000000000)).toString() + "P";
- }
+function sizify(bytes) {
+ if (bytes == 0) return "0";
+ if (bytes < 0) bytes = -bytes;
+ var prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
+ var exponent = Math.floor(Math.log10 ? Math.log10(bytes) : (Math.log(bytes) / Math.log(10)));
+ var prefixIndex = Math.floor(exponent / 3);
+ if (prefixIndex >= prefixes.length - 1) prefixIndex = prefixes.length - 1;
+ var prefixIndexMod = exponent - (prefixIndex * 3);
+ return (Math.round(bytes / Math.pow(10, Math.max(0, exponent - Math.max(2, prefixIndexMod)))) / (exponent > 2 ? Math.pow(10, Math.max(0, 2 - prefixIndexMod)) : 1)).toString() + prefixes[prefixIndex];
}
function getOS() {
@@ -3356,15 +3332,7 @@ if (!cluster.isPrimary) {
return;
}
- if (version.indexOf("Nightly-") === 0 && (href == "/invoke500.svr" || (os.platform() == "win32" && href.toLowerCase() == "/invoke500.svr"))) {
- if (uobject.query.crash !== undefined) throw new Error("Intentionally crashed");
- try {
- throw new Error("This page is intended to return 500 code.");
- } catch (err) {
- callServerError(500, undefined, generateErrorStack(err));
- return;
- }
- } else if (allowStatus && (href == "/svrjsstatus.svr" || (os.platform() == "win32" && href.toLowerCase() == "/svrjsstatus.svr"))) {
+ if (allowStatus && (href == "/svrjsstatus.svr" || (os.platform() == "win32" && href.toLowerCase() == "/svrjsstatus.svr"))) {
function formatRelativeTime(relativeTime) {
var days = Math.floor(relativeTime / 60 / (60 * 24));
var dateDiff = new Date(relativeTime * 1000);
@@ -3375,10 +3343,6 @@ if (!cluster.isPrimary) {
res.writeHead(200, "OK", hdhds);
res.end((head == "" ? "SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(//g, ">")) + "" : head.replace(//i, "SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(//g, ">")) + "")) + "SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(//g, ">")) + "
Server version: " + (exposeServerVersion ? "SVR.JS/" + version + " (" + getOS() + "; " + (process.isBun ? ("Bun/v" + process.versions.bun + "; like Node.JS/" + process.version) : ("Node.JS/" + process.version)) + ")" : "SVR.JS") + "
Current time: " + new Date().toString() + "
Thread start time: " + new Date(new Date() - (process.uptime() * 1000)).toString() + "
Thread uptime: " + formatRelativeTime(Math.floor(process.uptime())) + "
OS uptime: " + formatRelativeTime(os.uptime()) + "
Total request count: " + reqcounter + "
Average request rate: " + (Math.round((reqcounter / process.uptime()) * 100) / 100) + " requests/s" + (process.memoryUsage ? ("
Memory usage of thread: " + sizify(process.memoryUsage().rss) + "B") : "") + (process.cpuUsage ? ("
Total CPU usage by thread: u" + (process.cpuUsage().user / 1000) + "ms s" + (process.cpuUsage().system / 1000) + "ms - " + (Math.round((((process.cpuUsage().user + process.cpuUsage().system) / 1000000) / process.uptime()) * 1000) / 1000) + "%") : "") + "
Thread PID: " + process.pid + "
" + (foot == "" ? "" : foot));
return;
- } else if (version.indexOf("Nightly-") === 0 && (href == "/crash.svr" || (os.platform() == "win32" && href.toLowerCase() == "/crash.svr"))) {
- process.nextTick(function () {
- throw new Error("Intentionally crashed");
- });
}
/////////////////////////////////////////////
@@ -3432,46 +3396,42 @@ if (!cluster.isPrimary) {
// Check if index file exists
if (req.url == "/" || stats.isDirectory()) {
- fs.stat(readFrom + "/.notindex".replace(/\/+/g, "/"), function (e) {
- if (e) {
- fs.stat((readFrom + "/index.html").replace(/\/+/g, "/"), function (e, s) {
+ fs.stat((readFrom + "/index.html").replace(/\/+/g, "/"), function (e, s) {
+ if (e || !s.isFile()) {
+ fs.stat((readFrom + "/index.htm").replace(/\/+/g, "/"), function (e, s) {
if (e || !s.isFile()) {
- fs.stat((readFrom + "/index.htm").replace(/\/+/g, "/"), function (e, s) {
- if (e || !s.isFile()) {
- fs.stat((readFrom + "/index.xhtml").replace(/\/+/g, "/"), function (e, s) {
- if (e || !s.isFile()) {
- properDirectoryListingServe();
- } else {
- stats = s;
- pth = (pth + "/index.xhtml").replace(/\/+/g, "/");
- ext = "xhtml";
- readFrom = "./" + pth;
- properDirectoryListingServe();
- }
- });
- } else {
- stats = s;
- pth = (pth + "/index.htm").replace(/\/+/g, "/");
- ext = "htm";
- readFrom = "./" + pth;
- properDirectoryListingServe();
- }
- });
+ fs.stat((readFrom + "/index.xhtml").replace(/\/+/g, "/"), function (e, s) {
+ if (e || !s.isFile()) {
+ properDirectoryListingAndStaticFileServe();
+ } else {
+ stats = s;
+ pth = (pth + "/index.xhtml").replace(/\/+/g, "/");
+ ext = "xhtml";
+ readFrom = "./" + pth;
+ properDirectoryListingAndStaticFileServe();
+ }
+ });
} else {
stats = s;
- pth = (pth + "/index.html").replace(/\/+/g, "/");
- ext = "html";
+ pth = (pth + "/index.htm").replace(/\/+/g, "/");
+ ext = "htm";
readFrom = "./" + pth;
- properDirectoryListingServe();
+ properDirectoryListingAndStaticFileServe();
}
});
+ } else {
+ stats = s;
+ pth = (pth + "/index.html").replace(/\/+/g, "/");
+ ext = "html";
+ readFrom = "./" + pth;
+ properDirectoryListingAndStaticFileServe();
}
});
} else {
- properDirectoryListingServe();
+ properDirectoryListingAndStaticFileServe();
}
- function properDirectoryListingServe() {
+ function properDirectoryListingAndStaticFileServe() {
if (stats.isDirectory()) {
// Check if directory listing is enabled in the configuration
if (checkForEnabledDirectoryListing(req.headers.host)) {
diff --git a/tests.html b/tests.html
index 666a858..25c7100 100644
--- a/tests.html
+++ b/tests.html
@@ -1,7 +1,7 @@
- SVR.JS 3.10.0 Tests
+ SVR.JS 3.10.1 Tests
- SVR.JS 3.10.0 Tests
+ SVR.JS 3.10.1 Tests
Directory
Directory (with query)
diff --git a/views.txt b/views.txt
deleted file mode 100644
index 56a6051..0000000
--- a/views.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
\ No newline at end of file