@nuxtjs/redirect-module
Advanced tools
Comparing version
@@ -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) |
@@ -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 |
@@ -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", |
7403
4.44%29
3.57%