1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-14 14:42:55 +01:00
server/patches/i18next-http-middleware+3.1.1.patch

275 lines
10 KiB
Diff
Raw Normal View History

2021-02-16 20:35:47 +01:00
diff --git a/node_modules/i18next-http-middleware/cjs/httpFunctions.js b/node_modules/i18next-http-middleware/cjs/httpFunctions.js
2021-05-05 15:05:23 +02:00
index 47f0d61..c1ebebc 100644
2021-02-16 20:35:47 +01:00
--- a/node_modules/i18next-http-middleware/cjs/httpFunctions.js
+++ b/node_modules/i18next-http-middleware/cjs/httpFunctions.js
@@ -1,175 +1,181 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
- value: true
+ value: true,
});
exports.extendOptionsWithDefaults = exports.getSession = exports.send = exports.setStatus = exports.setContentType = exports.setHeader = exports.getHeader = exports.getBody = exports.getCookies = exports.getHeaders = exports.getParams = exports.getQuery = exports.getOriginalUrl = exports.setUrl = exports.getUrl = exports.getPath = void 0;
var getPath = function getPath(req) {
- if (req.path) return req.path;
- if (req.raw && req.raw.path) return req.raw.path;
- if (req.url) return req.url;
- console.log('no possibility found to get path');
+ if (req.path) return req.path;
+ if (req.raw && req.raw.path) return req.raw.path;
+ if (req.url) return req.url;
+ console.log("no possibility found to get path");
};
exports.getPath = getPath;
var getUrl = function getUrl(req) {
- if (req.url) return req.url;
- if (req.raw && req.raw.url) return req.raw.url;
- console.log('no possibility found to get url');
+ if (req.url) return req.url;
+ if (req.raw && req.raw.url) return req.raw.url;
+ console.log("no possibility found to get url");
};
exports.getUrl = getUrl;
var setUrl = function setUrl(req, url) {
- if (req.url) {
- req.url = url;
- return;
- }
+ if (req.url) {
+ req.url = url;
+ return;
+ }
- console.log('no possibility found to get url');
+ console.log("no possibility found to get url");
};
exports.setUrl = setUrl;
var getOriginalUrl = function getOriginalUrl(req) {
- if (req.originalUrl) return req.originalUrl;
- if (req.raw && req.raw.originalUrl) return req.raw.originalUrl;
- return getUrl(req);
+ if (req.originalUrl) return req.originalUrl;
+ if (req.raw && req.raw.originalUrl) return req.raw.originalUrl;
+ return getUrl(req);
};
exports.getOriginalUrl = getOriginalUrl;
var getQuery = function getQuery(req) {
- if (req.query && typeof req.query.entries === 'function' && typeof Object.fromEntries === 'function') return Object.fromEntries(req.query);
- if (req.query) return req.query;
- if (req.raw && req.raw.query) return req.raw.query;
- if (req.ctx && req.ctx.queryParams) return req.ctx.queryParams;
- var url = req.url || req.raw && req.raw.url;
- if (url && url.indexOf('?') < 0) return {};
- console.log('no possibility found to get query');
- return {};
+ try {
+ if (req.query && typeof req.query.entries === "function" && typeof Object.fromEntries === "function")
+ return Object.fromEntries(req.query);
+ } catch (e) {}
+
+ if (req.query) return req.query;
+ if (req.raw && req.raw.query) return req.raw.query;
+ if (req.ctx && req.ctx.queryParams) return req.ctx.queryParams;
+ var url = req.url || (req.raw && req.raw.url);
+ if (url && url.indexOf("?") < 0) return {};
+ console.log("no possibility found to get query");
+ return {};
};
exports.getQuery = getQuery;
var getParams = function getParams(req) {
- if (req.params) return req.params;
- if (req.raw && req.raw.params) return req.raw.params;
- if (req.ctx && req.ctx.params) return req.ctx.params;
- console.log('no possibility found to get params');
- return {};
+ if (req.params) return req.params;
+ if (req.raw && req.raw.params) return req.raw.params;
+ if (req.ctx && req.ctx.params) return req.ctx.params;
+ console.log("no possibility found to get params");
+ return {};
};
exports.getParams = getParams;
var getHeaders = function getHeaders(req) {
- if (req.headers) return req.headers;
- console.log('no possibility found to get headers');
+ if (req.headers) return req.headers;
+ console.log("no possibility found to get headers");
};
exports.getHeaders = getHeaders;
var getCookies = function getCookies(req) {
- if (req.cookies) return req.cookies;
+ if (req.cookies) return req.cookies;
- if (getHeaders(req)) {
- var list = {};
- var rc = getHeaders(req).cookie;
- rc && rc.split(';').forEach(function (cookie) {
- var parts = cookie.split('=');
- list[parts.shift().trim()] = decodeURI(encodeURI(parts.join('=')));
- });
- return list;
- }
+ if (getHeaders(req)) {
+ var list = {};
+ var rc = getHeaders(req).cookie;
+ rc &&
+ rc.split(";").forEach(function (cookie) {
+ var parts = cookie.split("=");
+ list[parts.shift().trim()] = decodeURI(encodeURI(parts.join("=")));
+ });
+ return list;
+ }
- console.log('no possibility found to get cookies');
+ console.log("no possibility found to get cookies");
};
exports.getCookies = getCookies;
var getBody = function getBody(req) {
- if (req.ctx && typeof req.ctx.body === 'function') return req.ctx.body.bind(req.ctx);
- if (req.ctx && req.ctx.body) return req.ctx.body;
- if (req.json) return req.json;
- if (req.body) return req.body;
- console.log('no possibility found to get body');
- return {};
+ if (req.ctx && typeof req.ctx.body === "function") return req.ctx.body.bind(req.ctx);
+ if (req.ctx && req.ctx.body) return req.ctx.body;
+ if (req.json) return req.json;
+ if (req.body) return req.body;
+ console.log("no possibility found to get body");
+ return {};
};
exports.getBody = getBody;
var getHeader = function getHeader(res, name) {
- if (res.getHeader) return res.getHeader(name);
- if (res.headers) return res.headers[name];
- if (getHeaders(res) && getHeaders(res)[name]) return getHeaders(res)[name];
- console.log('no possibility found to get header');
- return undefined;
+ if (res.getHeader) return res.getHeader(name);
+ if (res.headers) return res.headers[name];
+ if (getHeaders(res) && getHeaders(res)[name]) return getHeaders(res)[name];
+ console.log("no possibility found to get header");
+ return undefined;
};
exports.getHeader = getHeader;
var setHeader = function setHeader(res, name, value) {
- if (res._headerSent || res.headersSent) return;
- if (typeof res.setHeader === 'function') return res.setHeader(name, value);
- if (typeof res.header === 'function') return res.header(name, value);
- if (res.responseHeaders && typeof res.responseHeaders.set === 'function') return res.responseHeaders.set(name, value);
- if (res.headers && typeof res.headers.set === 'function') return res.headers.set(name, value);
- console.log('no possibility found to set header');
+ if (res._headerSent || res.headersSent) return;
+ if (typeof res.setHeader === "function") return res.setHeader(name, value);
+ if (typeof res.header === "function") return res.header(name, value);
+ if (res.responseHeaders && typeof res.responseHeaders.set === "function")
+ return res.responseHeaders.set(name, value);
+ if (res.headers && typeof res.headers.set === "function") return res.headers.set(name, value);
+ console.log("no possibility found to set header");
};
exports.setHeader = setHeader;
var setContentType = function setContentType(res, type) {
- if (typeof res.contentType === 'function') return res.contentType(type);
- if (typeof res.type === 'function') return res.type(type);
- setHeader(res, 'Content-Type', type);
+ if (typeof res.contentType === "function") return res.contentType(type);
+ if (typeof res.type === "function") return res.type(type);
+ setHeader(res, "Content-Type", type);
};
exports.setContentType = setContentType;
var setStatus = function setStatus(res, code) {
- if (typeof res.status === 'function') return res.status(code);
- if (res.status) return res.status = code;
- console.log('no possibility found to set status');
+ if (typeof res.status === "function") return res.status(code);
+ if (res.status) return (res.status = code);
+ console.log("no possibility found to set status");
};
exports.setStatus = setStatus;
var send = function send(res, body) {
- if (typeof res.send === 'function') return res.send(body);
- return body;
+ if (typeof res.send === "function") return res.send(body);
+ return body;
};
exports.send = send;
var getSession = function getSession(req) {
- if (req.session) return req.session;
- if (req.raw && req.raw.session) return req.raw.session;
- console.log('no possibility found to get session');
+ if (req.session) return req.session;
+ if (req.raw && req.raw.session) return req.raw.session;
+ console.log("no possibility found to get session");
};
exports.getSession = getSession;
var extendOptionsWithDefaults = function extendOptionsWithDefaults() {
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- options.getPath = options.getPath || getPath;
- options.getOriginalUrl = options.getOriginalUrl || getOriginalUrl;
- options.getUrl = options.getUrl || getUrl;
- options.setUrl = options.setUrl || setUrl;
- options.getParams = options.getParams || getParams;
- options.getSession = options.getSession || getSession;
- options.getQuery = options.getQuery || getQuery;
- options.getCookies = options.getCookies || getCookies;
- options.getBody = options.getBody || getBody;
- options.getHeaders = options.getHeaders || getHeaders;
- options.getHeader = options.getHeader || getHeader;
- options.setHeader = options.setHeader || setHeader;
- options.setContentType = options.setContentType || setContentType;
- options.setStatus = options.setStatus || setStatus;
- options.send = options.send || send;
- return options;
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+ options.getPath = options.getPath || getPath;
+ options.getOriginalUrl = options.getOriginalUrl || getOriginalUrl;
+ options.getUrl = options.getUrl || getUrl;
+ options.setUrl = options.setUrl || setUrl;
+ options.getParams = options.getParams || getParams;
+ options.getSession = options.getSession || getSession;
+ options.getQuery = options.getQuery || getQuery;
+ options.getCookies = options.getCookies || getCookies;
+ options.getBody = options.getBody || getBody;
+ options.getHeaders = options.getHeaders || getHeaders;
+ options.getHeader = options.getHeader || getHeader;
+ options.setHeader = options.setHeader || setHeader;
+ options.setContentType = options.setContentType || setContentType;
+ options.setStatus = options.setStatus || setStatus;
+ options.send = options.send || send;
+ return options;
};
exports.extendOptionsWithDefaults = extendOptionsWithDefaults;
2021-05-05 15:05:23 +02:00
\ No newline at end of file