Socket
Socket
Sign inDemoInstall

@ladjs/i18n

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ladjs/i18n - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

21

lib/index.js

@@ -13,4 +13,2 @@ "use strict";

const autoBind = require('auto-bind');
const boolean = require('boolean');

@@ -26,2 +24,4 @@

const multimatch = require('multimatch');
const titleize = require('titleize');

@@ -65,3 +65,4 @@

register: i18n.api,
lastLocaleField: 'last_locale'
lastLocaleField: 'last_locale',
ignoredRedirectGlobs: []
}, config); // validate locales against available ones

@@ -74,3 +75,5 @@

this.configure(this.config);
autoBind(this);
this.translate = this.translate.bind(this);
this.middleware = this.middleware.bind(this);
this.redirect = this.redirect.bind(this);
}

@@ -174,5 +177,13 @@

if (extname(ctx.path) !== '') return next(); // inspired by nodejs.org language support
if (extname(ctx.path) !== '') return next(); // check against ignored/whitelisted redirect middleware paths
const match = multimatch(ctx.path, _this.config.ignoredRedirectGlobs);
if (Array.isArray(match) && match.length > 0) {
debug(`multimatch found matches for ${ctx.path}:`, match);
return next();
} // inspired by nodejs.org language support
// <https://github.com/nodejs/nodejs.org/commit/d6cdd942a8fc0fffcf6879eca124295e95991bbc#diff-78c12f5adc1848d13b1c6f07055d996eR59>
const locale = ctx.url.split('/')[1].split('?')[0];

@@ -179,0 +190,0 @@

{
"name": "@ladjs/i18n",
"description": "i18n wrapper and Koa middleware for Lad",
"version": "1.2.1",
"version": "1.2.2",
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",

@@ -23,37 +23,37 @@ "ava": {

"dependencies": {
"@hapi/boom": "^7.4.3",
"auto-bind": "^2.1.0",
"boolean": "^1.0.0",
"@hapi/boom": "^8.0.1",
"boolean": "1.0.0",
"country-language": "^0.1.7",
"debug": "^4.1.1",
"i18n": "^0.8.3",
"i18n": "^0.8.4",
"i18n-locales": "^0.0.2",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"qs": "^6.8.0",
"multimatch": "^4.0.0",
"qs": "^6.9.1",
"titleize": "^2.1.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"ava": "^2.3.0",
"codecov": "^3.5.0",
"cross-env": "^5.2.1",
"eslint": "^6.3.0",
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"ava": "^2.4.0",
"codecov": "^3.6.1",
"cross-env": "^6.0.3",
"eslint": "^6.6.0",
"eslint-config-xo-lass": "^1.0.3",
"eslint-plugin-node": "^10.0.0",
"fixpack": "^2.3.1",
"husky": "^3.0.5",
"koa": "^2.8.1",
"husky": "^3.1.0",
"koa": "^2.11.0",
"koa-generic-session": "^2.0.1",
"lint-staged": "^9.2.5",
"lint-staged": "^9.4.3",
"nyc": "^14.1.1",
"remark-cli": "^7.0.0",
"remark-cli": "^7.0.1",
"remark-preset-github": "^0.0.16",
"sinon": "^7.4.2",
"sinon": "^7.5.0",
"supertest": "^4.0.2",
"xo": "^0.24.0"
"xo": "0.24"
},

@@ -60,0 +60,0 @@ "engines": {

@@ -92,2 +92,4 @@ # [**@ladjs/i18n**](https://github.com/ladjs/i18n)

**NOTE:** As of v1.2.2 we have added a `ignoredRedirectGlobs` option you can pass to `new I18N({ ... })` which will ignore these paths for locale redirection. This is incredibly useful if you are using authentication providers and the `passport` library, e.g. you want to set `/auth/github/ok` as the callback URL for GitHub, but a redirect to `/en/auth/github/ok` would have occurred, thus causing authentication to fail due to a bad code. In this case, you would set `{ ignoredRedirectGlobs: [ '/auth/**/*' ] }` or simply `[ '/auth/google/ok' ]`. This package uses [multimatch][] internally which supports an Array, therefore you could negate certain paths if needed. See the documentation for [multimatch][] for more insight.
It also sets the cookie `locale` for future requests to their detected locale.

@@ -127,3 +129,4 @@

register: i18n.api,
lastLocaleField: 'last_locale'
lastLocaleField: 'last_locale',
ignoredRedirectGlobs: []
});

@@ -180,1 +183,3 @@ ```

[cabin]: https://cabinjs.com
[multimatch]: https://github.com/sindresorhus/multimatch
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