i18next-http-middleware 3.9.3 → 3.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +9 -2
- package/esm/index.js +9 -2
- package/lib/index.js +11 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -173,7 +173,7 @@ function koaPlugin(i18next, options) {
|
|
|
173
173
|
function freshPlugin(i18next, options) {
|
|
174
174
|
return function () {
|
|
175
175
|
var _ref = _asyncToGenerator(_regenerator().m(function _callee2(ctx) {
|
|
176
|
-
var placeholder, resp;
|
|
176
|
+
var placeholder, resp, contentLanguage, setCookie;
|
|
177
177
|
return _regenerator().w(function (_context2) {
|
|
178
178
|
while (1) switch (_context2.n) {
|
|
179
179
|
case 0:
|
|
@@ -192,7 +192,14 @@ function freshPlugin(i18next, options) {
|
|
|
192
192
|
return ctx.next();
|
|
193
193
|
case 1:
|
|
194
194
|
resp = _context2.v;
|
|
195
|
-
|
|
195
|
+
contentLanguage = placeholder.headers.get('Content-Language');
|
|
196
|
+
if (contentLanguage) {
|
|
197
|
+
resp.headers.set('Content-Language', contentLanguage);
|
|
198
|
+
}
|
|
199
|
+
setCookie = placeholder.headers.get('Set-Cookie');
|
|
200
|
+
if (setCookie) {
|
|
201
|
+
resp.headers.set('Set-Cookie', setCookie);
|
|
202
|
+
}
|
|
196
203
|
return _context2.a(2, resp);
|
|
197
204
|
}
|
|
198
205
|
}, _callee2);
|
package/esm/index.js
CHANGED
|
@@ -156,7 +156,7 @@ export function koaPlugin(i18next, options) {
|
|
|
156
156
|
export function freshPlugin(i18next, options) {
|
|
157
157
|
return function () {
|
|
158
158
|
var _ref = _asyncToGenerator(_regenerator().m(function _callee2(ctx) {
|
|
159
|
-
var placeholder, resp;
|
|
159
|
+
var placeholder, resp, contentLanguage, setCookie;
|
|
160
160
|
return _regenerator().w(function (_context2) {
|
|
161
161
|
while (1) switch (_context2.n) {
|
|
162
162
|
case 0:
|
|
@@ -175,7 +175,14 @@ export function freshPlugin(i18next, options) {
|
|
|
175
175
|
return ctx.next();
|
|
176
176
|
case 1:
|
|
177
177
|
resp = _context2.v;
|
|
178
|
-
|
|
178
|
+
contentLanguage = placeholder.headers.get('Content-Language');
|
|
179
|
+
if (contentLanguage) {
|
|
180
|
+
resp.headers.set('Content-Language', contentLanguage);
|
|
181
|
+
}
|
|
182
|
+
setCookie = placeholder.headers.get('Set-Cookie');
|
|
183
|
+
if (setCookie) {
|
|
184
|
+
resp.headers.set('Set-Cookie', setCookie);
|
|
185
|
+
}
|
|
179
186
|
return _context2.a(2, resp);
|
|
180
187
|
}
|
|
181
188
|
}, _callee2);
|
package/lib/index.js
CHANGED
|
@@ -162,7 +162,17 @@ export function freshPlugin (i18next, options) {
|
|
|
162
162
|
const placeholder = ctx.state.res
|
|
163
163
|
delete ctx.state.res
|
|
164
164
|
const resp = await ctx.next()
|
|
165
|
-
|
|
165
|
+
|
|
166
|
+
const contentLanguage = placeholder.headers.get('Content-Language')
|
|
167
|
+
if (contentLanguage) {
|
|
168
|
+
resp.headers.set('Content-Language', contentLanguage)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const setCookie = placeholder.headers.get('Set-Cookie')
|
|
172
|
+
if (setCookie) {
|
|
173
|
+
resp.headers.set('Set-Cookie', setCookie)
|
|
174
|
+
}
|
|
175
|
+
|
|
166
176
|
return resp
|
|
167
177
|
}
|
|
168
178
|
}
|