summary refs log tree commit diff
path: root/patches/i18next-http-middleware+3.1.1.patch
blob: 5790ae0db15f5d6b9ba91646ca9ca2cc22d0f9f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
diff --git a/node_modules/i18next-http-middleware/cjs/httpFunctions.js b/node_modules/i18next-http-middleware/cjs/httpFunctions.js
index 47f0d61..c1ebebc 100644
--- 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;
\ No newline at end of file