Socket
Socket
Sign inDemoInstall

i18next-express-middleware

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-express-middleware - npm Package Compare versions

Comparing version 1.0.7 to 1.0.9

.npmignore

3

CHANGELOG.md

@@ -0,1 +1,4 @@

### 1.0.8
- Guard against non-string detections [PR141](https://github.com/i18next/i18next-express-middleware/pull/141)
### 1.0.7

@@ -2,0 +5,0 @@ - Fix path detection can crash app (if req.originalUrl is not set) [#137](https://github.com/i18next/i18next-express-middleware/pull/137)

2

lib/index.js

@@ -27,3 +27,3 @@ 'use strict';

function handle(i18next) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -30,0 +30,0 @@ return function (req, res, next) {

@@ -56,4 +56,4 @@ 'use strict';

function LanguageDetector(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var allOptions = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

@@ -71,4 +71,4 @@ _classCallCheck(this, LanguageDetector);

value: function init(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var allOptions = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

@@ -104,6 +104,6 @@ this.services = services;

if (!detections) return;
if (typeof detections === 'string') detections = [detections];
if (!Array.isArray(detections)) detections = [detections];
detections.forEach(function (lng) {
if (found) return;
if (found || typeof lng !== 'string') return;

@@ -110,0 +110,0 @@ var cleanedLng = _this.services.languageUtils.formatLanguageCode(lng);

@@ -31,3 +31,3 @@ 'use strict';

cacheUserLanguage: function cacheUserLanguage(req, res, lng) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];

@@ -34,0 +34,0 @@ if (options.lookupCookie && req !== 'undefined') {

@@ -20,33 +20,35 @@ 'use strict';

if (acceptLanguage) {
var lngs = [],
i = void 0;
(function () {
var lngs = [],
i = void 0;
// associate language tags by their 'q' value (between 1 and 0)
acceptLanguage.split(',').forEach(function (l) {
var parts = l.split(';'); // 'en-GB;q=0.8' -> ['en-GB', 'q=0.8']
// associate language tags by their 'q' value (between 1 and 0)
acceptLanguage.split(',').forEach(function (l) {
var parts = l.split(';'); // 'en-GB;q=0.8' -> ['en-GB', 'q=0.8']
// get the language tag qvalue: 'q=0.8' -> 0.8
var qvalue = 1; // default qvalue
// get the language tag qvalue: 'q=0.8' -> 0.8
var qvalue = 1; // default qvalue
for (i = 0; i < parts.length; i++) {
var part = parts[i].split('=');
if (part[0] === 'q' && !isNaN(part[1])) {
qvalue = Number(part[1]);
break;
for (i = 0; i < parts.length; i++) {
var part = parts[i].split('=');
if (part[0] === 'q' && !isNaN(part[1])) {
qvalue = Number(part[1]);
break;
}
}
}
// add the tag and primary subtag to the qvalue associations
lngs.push({ lng: parts[0], q: qvalue });
});
// add the tag and primary subtag to the qvalue associations
lngs.push({ lng: parts[0], q: qvalue });
});
lngs.sort(function (a, b) {
return b.q - a.q;
});
lngs.sort(function (a, b) {
return b.q - a.q;
});
for (i = 0; i < lngs.length; i++) {
locales.push(lngs[i].lng);
}
for (i = 0; i < lngs.length; i++) {
locales.push(lngs[i].lng);
}
if (locales.length) found = locales;
if (locales.length) found = locales;
})();
}

@@ -53,0 +55,0 @@ }

@@ -7,3 +7,3 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

@@ -23,3 +23,3 @@ exports.default = {

cacheUserLanguage: function cacheUserLanguage(req, res, lng) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];

@@ -26,0 +26,0 @@ if (options.lookupSession && req && req.session) {

{
"name": "i18next-express-middleware",
"version": "1.0.7",
"version": "1.0.9",
"description": "express middleware for i18next",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc