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

@ladjs/i18n

Package Overview
Dependencies
Maintainers
3
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 3.0.13 to 4.0.0

18

lib/index.js

@@ -8,2 +8,3 @@ "use strict";

const _require = require('path'),
basename = _require.basename,
extname = _require.extname,

@@ -26,2 +27,4 @@ resolve = _require.resolve;

const tlds = require('tlds');
const _require2 = require('boolean'),

@@ -42,2 +45,7 @@ boolean = _require2.boolean;

const _require6 = require('punycode/'),
toASCII = _require6.toASCII;
const punycodedTlds = tlds.map(tld => toASCII(tld));
class I18N {

@@ -75,3 +83,4 @@ constructor(config = {}) {

arrayFormat: 'indices'
}
},
redirectTLDS: true
}, config); // validate locales against available ones

@@ -216,4 +225,9 @@

if (extname(ctx.path) !== '') return next(); // if the method is not a GET request then ignore it
if (extname(ctx.path) !== '') {
if (!_this.config.redirectTLDS) return next();
const asciiFile = toASCII(basename(ctx.path));
if (!punycodedTlds.some(tld => asciiFile.endsWith(`.${tld}`))) return next();
} // if the method is not a GET request then ignore it
if (_this.config.redirectIgnoresNonGetMethods && ctx.method !== 'GET') return next(); // check against ignored/whitelisted redirect middleware paths

@@ -220,0 +234,0 @@

6

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

@@ -33,4 +33,6 @@ "ava": {

"multimatch": "^4.0.0",
"punycode": "^2.1.1",
"qs": "^6.9.4",
"titleize": "^2.1.0"
"titleize": "^2.1.0",
"tlds": "^1.207.0"
},

@@ -37,0 +39,0 @@ "devDependencies": {

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

* [Install](#install)
* [Important Note](#important-note)
* [Usage](#usage)

@@ -25,2 +24,3 @@ * [API](#api)

* [Options](#options)
* [Redirect exceptions](#redirect-exceptions)
* [Contributors](#contributors)

@@ -45,11 +45,2 @@ * [License](#license)

## Important Note
If you have an extension in your route, e.g. `foo.css` or `foo.com`, then the i18n middleware we expose (see below) will not effect this.
We have considered accepting a pull request to handle detection of file extension (e.g. if it is a domain name) or another way to allow certain routes to bypass this.
Thank you, and let us know if you have any issues!
## Usage

@@ -159,3 +150,4 @@

arrayFormat: 'indices'
}
},
redirectTLDS: true
});

@@ -179,2 +171,11 @@ ```

## Redirect exceptions
If the path has an extension, then it is not redirected.
However if `redirectTLDS` option is `true` (which is `true` by default as of v4.0.0), then if the path basename ends with a valid TLD, then it is redirected.
We came across this missing feature and added it after our discovery through [Forward Email](https://forwardemail.net).
## Contributors

@@ -181,0 +182,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