diff --git a/src/executor/nginx.js b/src/executor/nginx.js index a4e8bda..1d83f98 100644 --- a/src/executor/nginx.js +++ b/src/executor/nginx.js @@ -43,7 +43,7 @@ class NginxExecutor { switch (key) { case "env_var_list": config.passenger[key].forEach((/** @type {String} */ v) => { - var splt = splitLimit(v, /=/g, 2); + var splt = splitLimit(v, /[= ]/g, 2); if (splt.length == 2) { node._add("passenger_env_var", splt[0] + ' ' + escapeNginx(splt[1])); } @@ -51,7 +51,7 @@ class NginxExecutor { continue; case "set_header_list": config.passenger[key].forEach((/** @type {String} */ v) => { - var splt = splitLimit(v, /=/g, 2); + var splt = splitLimit(v, /[= ]/g, 2); if (splt.length == 2) { node._add("passenger_set_header", splt[0] + ' ' + escapeNginx(splt[1])); } @@ -176,7 +176,7 @@ class NginxExecutor { for (const env of node[k]) { var splt = splitLimit(env._value, / /g, 2); if (splt.length == 2) { - r.passenger["set_header_list"].push(splt[0] + '=' + unescapeNginx(splt[1])); + r.passenger["set_header_list"].push(splt[0] + ' ' + unescapeNginx(splt[1])); } } break; diff --git a/src/index.js b/src/index.js index 6b7f99b..e5a7f20 100644 --- a/src/index.js +++ b/src/index.js @@ -13,6 +13,7 @@ import runner from './controllers/runner.js'; import virtualmin from './controllers/virtualmin.js'; import podman from './controllers/podman.js'; +const startTime = Date.now(); dotenv.config(); initUtils(); @@ -36,5 +37,6 @@ app.use(function (err, req, res, next) { const port = process.env.PORT ? parseInt(process.env.PORT) : 2223; app.listen(port, function () { console.log(`Listening on ${port}`); + console.log(`Start time takes ` + (Date.now() - startTime) / 1000 + ` s`) }) diff --git a/src/util.js b/src/util.js index 0a416fb..3be66fa 100644 --- a/src/util.js +++ b/src/util.js @@ -501,7 +501,9 @@ export const unescapeNginx = function ( /** @type {string} */ str) { // https://stackoverflow.com/a/64296576 export function splitLimit(/** @type {string} */ input,/** @type {string|RegExp} */ separator, /** @type {Number} */ limit) { // Ensure the separator is global - separator = new RegExp(separator, 'g'); + if (!(separator instanceof RegExp) || !separator.global) { + separator = new RegExp(separator, 'g'); + } // Allow the limit argument to be excluded limit = limit ?? -1;