i18next-http-middleware 3.1.4 → 3.1.5

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -31,7 +31,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
31
31
 
32
32
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
33
33
 
34
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
34
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
35
35
 
36
36
  function getDefaults() {
37
37
  return (0, _httpFunctions.extendOptionsWithDefaults)({
@@ -117,6 +117,7 @@ var LanguageDetector = function () {
117
117
 
118
118
  if (!found) {
119
119
  var fallbacks = this.allOptions.fallbackLng;
120
+ if (typeof fallbacks === 'function') fallbacks = fallbacks();
120
121
  if (typeof fallbacks === 'string') fallbacks = [fallbacks];
121
122
  if (!fallbacks) fallbacks = [];
122
123
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- 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;
6
+ exports.setUrl = exports.setStatus = exports.setHeader = exports.setContentType = exports.send = exports.getUrl = exports.getSession = exports.getQuery = exports.getPath = exports.getParams = exports.getOriginalUrl = exports.getHeaders = exports.getHeader = exports.getCookies = exports.getBody = exports.extendOptionsWithDefaults = void 0;
7
7
 
8
8
  var getPath = function getPath(req) {
9
9
  if (req.path) return req.path;
package/cjs/index.js CHANGED
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.handle = handle;
9
- exports.plugin = plugin;
8
+ exports.LanguageDetector = void 0;
9
+ exports.addRoute = addRoute;
10
+ exports.default = void 0;
10
11
  exports.getResourcesHandler = getResourcesHandler;
12
+ exports.handle = handle;
11
13
  exports.missingKeyHandler = missingKeyHandler;
12
- exports.addRoute = addRoute;
13
- exports.default = exports.LanguageDetector = void 0;
14
+ exports.plugin = plugin;
14
15
 
15
16
  var utils = _interopRequireWildcard(require("./utils.js"));
16
17
 
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
9
 
10
10
  var _default = {
11
11
  name: 'session',
package/cjs/utils.js CHANGED
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setPath = setPath;
7
6
  exports.defaults = defaults;
8
7
  exports.extend = extend;
9
8
  exports.removeLngFromUrl = removeLngFromUrl;
9
+ exports.setPath = setPath;
10
10
 
11
11
  function setPath(object, path, newValue) {
12
12
  var stack;
@@ -2,7 +2,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
2
2
 
3
3
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4
4
 
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
6
 
7
7
  import * as utils from './utils.js';
8
8
  import cookieLookup from './languageLookups/cookie.js';
@@ -96,6 +96,7 @@ var LanguageDetector = function () {
96
96
 
97
97
  if (!found) {
98
98
  var fallbacks = this.allOptions.fallbackLng;
99
+ if (typeof fallbacks === 'function') fallbacks = fallbacks();
99
100
  if (typeof fallbacks === 'string') fallbacks = [fallbacks];
100
101
  if (!fallbacks) fallbacks = [];
101
102
 
@@ -1,4 +1,4 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
 
3
3
  export default {
4
4
  name: 'session',
@@ -79,9 +79,9 @@ class LanguageDetector {
79
79
 
80
80
  if (!found) {
81
81
  let fallbacks = this.allOptions.fallbackLng
82
+ if (typeof fallbacks === 'function') fallbacks = fallbacks()
82
83
  if (typeof fallbacks === 'string') fallbacks = [fallbacks]
83
84
  if (!fallbacks) fallbacks = []
84
-
85
85
  if (Object.prototype.toString.apply(fallbacks) === '[object Array]') {
86
86
  found = fallbacks[0]
87
87
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-http-middleware",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./cjs/index.js",
@@ -21,26 +21,26 @@
21
21
  "module": "./esm/index.js",
22
22
  "dependencies": {},
23
23
  "devDependencies": {
24
- "@babel/cli": "7.14.5",
25
- "@babel/core": "7.14.6",
26
- "@babel/preset-env": "7.14.7",
27
- "@types/express-serve-static-core": "^4.17.21",
24
+ "@babel/cli": "7.16.0",
25
+ "@babel/core": "7.16.5",
26
+ "@babel/preset-env": "7.16.5",
27
+ "@types/express-serve-static-core": "^4.17.27",
28
28
  "babel-plugin-add-module-exports": "1.0.4",
29
29
  "eslint": "7.29.0",
30
30
  "eslint-config-standard": "16.0.3",
31
- "eslint-plugin-import": "2.23.4",
31
+ "eslint-plugin-import": "2.25.3",
32
32
  "eslint-plugin-node": "11.1.0",
33
33
  "eslint-plugin-promise": "5.1.0",
34
34
  "eslint-plugin-require-path-exists": "1.1.9",
35
35
  "eslint-plugin-standard": "5.0.0",
36
36
  "expect.js": "0.3.1",
37
- "express": "4.17.1",
38
- "fastify": "3.18.0",
39
- "i18next": "20.3.2",
40
- "mocha": "9.0.1",
41
- "supertest": "6.1.3",
42
- "tsd": "0.17.0",
43
- "uglify-js": "3.13.9"
37
+ "express": "4.17.2",
38
+ "fastify": "3.25.2",
39
+ "i18next": "21.6.3",
40
+ "mocha": "9.1.3",
41
+ "supertest": "6.1.6",
42
+ "tsd": "0.19.0",
43
+ "uglify-js": "3.14.5"
44
44
  },
45
45
  "description": "i18next-http-middleware is a middleware to be used with Node.js web frameworks like express or Fastify and also for Deno.",
46
46
  "keywords": [
package/CHANGELOG.md DELETED
@@ -1,49 +0,0 @@
1
- ## [v3.1.4](https://github.com/i18next/i18next-http-middleware/compare/v3.1.3...v3.1.4)
2
- - fix for [point-of-view](https://github.com/fastify/point-of-view)
3
- - update all dependencies
4
-
5
- ## [v3.1.3](https://github.com/i18next/i18next-http-middleware/compare/v3.1.2...v3.1.3)
6
- - optimize getQuery() function to check if req.query is iterable
7
-
8
- ## [v3.1.2](https://github.com/i18next/i18next-http-middleware/compare/v3.1.1...v3.1.2)
9
- - fix the type of the lookup method [#37](https://github.com/i18next/i18next-http-middleware/pull/37)
10
-
11
- ## [v3.1.1](https://github.com/i18next/i18next-http-middleware/compare/v3.1.0...v3.1.1)
12
- - make sure no undefined language is detected
13
-
14
- ## [v3.1.0](https://github.com/i18next/i18next-http-middleware/compare/v3.0.6...v3.1.0)
15
- - added types
16
-
17
- ## [v3.0.6](https://github.com/i18next/i18next-http-middleware/compare/v3.0.5...v3.0.6)
18
- - ignoreCase option true by default
19
-
20
- ## [v3.0.5](https://github.com/i18next/i18next-http-middleware/compare/v3.0.4...v3.0.5)
21
- - introduce ignoreCase option
22
-
23
- ## [v3.0.4](https://github.com/i18next/i18next-http-middleware/compare/v3.0.3...v3.0.4)
24
- - fix language detection algorithm to handle fallbackLng correctly
25
-
26
- ## [v3.0.3](https://github.com/i18next/i18next-http-middleware/compare/v3.0.2...v3.0.3)
27
- - prevent URIError with cookie language detector
28
-
29
- ## [v3.0.2](https://github.com/i18next/i18next-http-middleware/compare/v3.0.1...v3.0.2)
30
- - transpile also esm
31
-
32
- ## [v3.0.1](https://github.com/i18next/i18next-http-middleware/compare/v3.0.0...v3.0.1)
33
- - introduce lookupHeaderRegex option
34
-
35
- ## [v3.0.0](https://github.com/i18next/i18next-http-middleware/compare/v2.1.2...v3.0.0)
36
- - **BREAKING** needs i18next >= 19.5.0
37
- - let i18next figure out which detected lng is best match
38
-
39
- ## [v2.1.2](https://github.com/i18next/i18next-http-middleware/compare/v2.1.1...v2.1.2)
40
- - fix: get whitelist from correct property
41
-
42
- ## [v2.1.1](https://github.com/i18next/i18next-http-middleware/compare/v2.1.0...v2.1.1)
43
- - extend httpFunctions getQuery to handle some edge cases
44
-
45
- ## [v2.1.0](https://github.com/i18next/i18next-http-middleware/compare/v2.0.0...v2.1.0)
46
- - LanguageDetector: cookie, new option: cookiePath
47
-
48
- ## [v2.0.0](https://github.com/i18next/i18next-http-middleware/compare/v1.3.1...v2.0.0)
49
- - potentially BREAKING: change cookie defaults: cookieSameSite: 'strict'