Socket
Book a DemoInstallSign in
Socket

@nuxtjs/redirect-module

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/redirect-module - npm Package Compare versions

Comparing version

to
0.1.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="0.1.0"></a>
# [0.1.0](https://github.com/nuxt-community/redirect-module/compare/v0.0.2...v0.1.0) (2018-08-24)
### Features
* support non-ascii URL redirects as well ([759e4bf](https://github.com/nuxt-community/redirect-module/commit/759e4bf))
<a name="0.0.2"></a>

@@ -7,0 +17,0 @@ ## [0.0.2](https://github.com/nuxt-community/redirect-module/compare/v0.0.1...v0.0.2) (2018-08-22)

5

lib/middleware.js

@@ -6,3 +6,4 @@ /* eslint-disable no-console */

return function redirectRoute (req, res, next) {
const foundRule = rules.find(o => o.from.test(req.url))
const decodedBaseUrl = decodeURI(req.url)
const foundRule = rules.find(o => o.from.test(decodedBaseUrl))

@@ -12,3 +13,3 @@ if (!foundRule) {

}
const toUrl = req.url.replace(foundRule.from, foundRule.to)
const toUrl = decodedBaseUrl.replace(foundRule.from, foundRule.to)

@@ -15,0 +16,0 @@ res.statusCode = foundRule.statusCode || 302

2

lib/module.js

@@ -12,3 +12,3 @@ module.exports = async function module (moduleOptions) {

// Transform each "from" value to a RegExp for later test
const regExpRules = initialRules.map(o => (Object.assign({}, { ...o, from: new RegExp(o.from) })))
const regExpRules = initialRules.map(o => (Object.assign({}, o, { from: new RegExp(o.from) })))
const middleware = require('./middleware.js')(regExpRules)

@@ -15,0 +15,0 @@

{
"name": "@nuxtjs/redirect-module",
"version": "0.0.2",
"version": "0.1.0",
"description": "",

@@ -5,0 +5,0 @@ "license": "MIT",