Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.5.0 to 1.6.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### 1.6.0
- Handle spaces in Accept-Language header [169](https://github.com/i18next/i18next-express-middleware/pull/169)
### 1.5.0

@@ -2,0 +6,0 @@

29

lib/languageLookups/header.js

@@ -21,23 +21,18 @@ 'use strict';

var lngs = [],
i = void 0;
i = void 0,
m = void 0;
var rgx = /(([a-z]{2})-?([A-Z]{2})?)\s*;?\s*(q=([0-9.]+))?/g;
// 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
for (i = 0; i < parts.length; i++) {
var part = parts[i].split('=');
if (part[0] === 'q' && !isNaN(part[1])) {
qvalue = Number(part[1]);
break;
do {
m = rgx.exec(acceptLanguage);
if (m) {
var lng = m[1],
weight = m[5] || '1',
q = Number(weight);
if (lng && !isNaN(q)) {
lngs.push({ lng: lng, q: q });
}
}
} while (m);
// add the tag and primary subtag to the qvalue associations
lngs.push({ lng: parts[0], q: qvalue });
});
lngs.sort(function (a, b) {

@@ -44,0 +39,0 @@ return b.q - a.q;

{
"name": "i18next-express-middleware",
"version": "1.5.0",
"version": "1.6.0",
"description": "express middleware for i18next",

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

@@ -51,3 +51,3 @@ # Introduction

```js
// missing keys
// missing keys; make sure the body is parsed (i.e. with [body-parser](https://github.com/expressjs/body-parser#bodyparserjsonoptions))
app.post("/locales/add/:lng/:ns", middleware.missingKeyHandler(i18next));

@@ -54,0 +54,0 @@

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