chore: release YellowSquare 1.1.4
This commit is contained in:
parent
705da378f1
commit
9bc6b3b37e
2 changed files with 22 additions and 6 deletions
26
index.js
26
index.js
|
@ -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() {}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
var detectedWwwroot = normalizedWebrootSupported ? normalizeWebroot(configJSON.wwwroot) : process.cwd();
|
||||
|
||||
function checkIfThereIsA401Rule() {
|
||||
var actually401 = false;
|
||||
|
||||
|
@ -118,7 +134,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
return;
|
||||
}
|
||||
try {
|
||||
var JSGIApp = require(process.cwd() + "/" + fname);
|
||||
var JSGIApp = require(detectedWwwroot + "/" + fname);
|
||||
var jsgiResponseObject = {};
|
||||
if (typeof JSGIApp === "object" && JSGIApp.app) {
|
||||
jsgiResponseObject = JSGIApp.app(jsgiRequestObject);
|
||||
|
@ -181,7 +197,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
input: inputStream,
|
||||
scriptName: a,
|
||||
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",
|
||||
env: {},
|
||||
jsgi: {
|
||||
|
@ -230,11 +246,11 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
jsgiRequestObject.host = pubip.replace(/^::ffff:/i, "");
|
||||
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" : ""))) {
|
||||
fs.stat("." + decodeURIComponent(href), function (err, stats) {
|
||||
fs.stat(detectedWwwroot + decodeURIComponent(href), function (err, stats) {
|
||||
if (!err) {
|
||||
if (!stats.isFile()) {
|
||||
elseCallback();
|
||||
|
@ -299,7 +315,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
if (!a) b = [];
|
||||
else var b = a.split("/");
|
||||
var isFile = false;
|
||||
fs.stat(pth, function (err, stats) {
|
||||
fs.stat(detectedWwwroot + "/" + pth, function (err, stats) {
|
||||
if (!err && stats.isFile()) {
|
||||
cb({
|
||||
fpth: pth,
|
||||
|
|
2
mod.info
2
mod.info
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "YellowSquare JSGI engine for SVR.JS",
|
||||
"version": "1.1.3"
|
||||
"version": "1.1.4"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue