chore: release YellowSquare 1.1.4

This commit is contained in:
Dorian Niemiec 2024-12-09 15:48:14 +01:00
parent 705da378f1
commit 9bc6b3b37e
2 changed files with 22 additions and 6 deletions

View file

@ -54,6 +54,20 @@ class ErrorStream extends stream.Writable {
} }
} }
var normalizedWebrootSupported = process.versions.svrjs && process.versions.svrjs.match(/^(?:Nightly-|(?:[5-9]|[1234][0-9])[0-9]*\.|4\.(?:(?:[1][0-9]|[2-9])+\.))/i);
function normalizeWebroot(currentWebroot) {
if (currentWebroot === undefined) {
return process.cwd();
} else if (!path.isAbsolute(currentWebroot)) {
return (
process.cwd() + (os.platform() == "win32" ? "\\" : "/") + currentWebroot
);
} else {
return currentWebroot;
}
}
function Mod() {} function Mod() {}
Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, ext, uobject, search, defaultpage, users, page404, head, foot, fd, elseCallback, configJSON, callServerError, getCustomHeaders, origHref, redirect, parsePostData, authUser) { Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, ext, uobject, search, defaultpage, users, page404, head, foot, fd, elseCallback, configJSON, callServerError, getCustomHeaders, origHref, redirect, parsePostData, authUser) {
@ -62,6 +76,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
configJSON = configJSONS; configJSON = configJSONS;
} }
var detectedWwwroot = normalizedWebrootSupported ? normalizeWebroot(configJSON.wwwroot) : process.cwd();
function checkIfThereIsA401Rule() { function checkIfThereIsA401Rule() {
var actually401 = false; var actually401 = false;
@ -118,7 +134,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
return; return;
} }
try { try {
var JSGIApp = require(process.cwd() + "/" + fname); var JSGIApp = require(detectedWwwroot + "/" + fname);
var jsgiResponseObject = {}; var jsgiResponseObject = {};
if (typeof JSGIApp === "object" && JSGIApp.app) { if (typeof JSGIApp === "object" && JSGIApp.app) {
jsgiResponseObject = JSGIApp.app(jsgiRequestObject); jsgiResponseObject = JSGIApp.app(jsgiRequestObject);
@ -181,7 +197,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
input: inputStream, input: inputStream,
scriptName: a, scriptName: a,
pathInfo: decodeURIComponent(b), pathInfo: decodeURIComponent(b),
pathTranslated: b ? ((process.cwd() + decodeURIComponent(require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : "", pathTranslated: b ? ((detectedWwwroot + decodeURIComponent(require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : "",
scheme: req.socket.encrypted ? "https" : "http", scheme: req.socket.encrypted ? "https" : "http",
env: {}, env: {},
jsgi: { jsgi: {
@ -230,11 +246,11 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
jsgiRequestObject.host = pubip.replace(/^::ffff:/i, ""); jsgiRequestObject.host = pubip.replace(/^::ffff:/i, "");
if (jsgiRequestObject.host.indexOf(":") != -1) jsgiRequestObject.host = "[" + jsgiRequestObject.host + "]"; if (jsgiRequestObject.host.indexOf(":") != -1) jsgiRequestObject.host = "[" + jsgiRequestObject.host + "]";
} }
executeJSGI("." + a, req, res, dh, jsgiRequestObject); executeJSGI(detectedWwwroot + a, req, res, dh, jsgiRequestObject);
} }
if (href.match(new RegExp("^/jsgi-bin(?:$|[?#/])",os.platform() == "win32" ? "i" : ""))) { if (href.match(new RegExp("^/jsgi-bin(?:$|[?#/])",os.platform() == "win32" ? "i" : ""))) {
fs.stat("." + decodeURIComponent(href), function (err, stats) { fs.stat(detectedWwwroot + decodeURIComponent(href), function (err, stats) {
if (!err) { if (!err) {
if (!stats.isFile()) { if (!stats.isFile()) {
elseCallback(); elseCallback();
@ -299,7 +315,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
if (!a) b = []; if (!a) b = [];
else var b = a.split("/"); else var b = a.split("/");
var isFile = false; var isFile = false;
fs.stat(pth, function (err, stats) { fs.stat(detectedWwwroot + "/" + pth, function (err, stats) {
if (!err && stats.isFile()) { if (!err && stats.isFile()) {
cb({ cb({
fpth: pth, fpth: pth,

View file

@ -1,4 +1,4 @@
{ {
"name": "YellowSquare JSGI engine for SVR.JS", "name": "YellowSquare JSGI engine for SVR.JS",
"version": "1.1.3" "version": "1.1.4"
} }