koa-lowercase
Advanced tools
Comparing version 0.4.2 to 0.5.0
20
dist.js
@@ -1,1 +0,19 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var lowercase=function(a,b){var c=a.request,d=c.origin,e=c.path,f=c.querystring,g=''+d+e;if(/[A-Z]/.test(g)&&!['POST','HEAD','PUT','DELETE'].includes(a.method)){var h=''+g.toLowerCase()+(f?'?'+f:'');return a.status=301,void a.redirect(h)}return b()};exports.default=lowercase; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const lowercase = async (ctx, next) => { | ||
const { origin, path, querystring } = ctx.request; | ||
const op = `${origin}${path}`; | ||
if (/[A-Z]/.test(op) && !['POST', 'HEAD', 'PUT', 'DELETE'].includes(ctx.method)) { | ||
const ld = `${op.toLowerCase()}${querystring ? '?' + querystring : ''}`; | ||
ctx.status = 301; | ||
ctx.redirect(ld); | ||
return; | ||
} | ||
return next(); | ||
}; | ||
exports.default = lowercase; |
@@ -1,2 +0,2 @@ | ||
const lowercase = (ctx, next) => { | ||
const lowercase = async (ctx, next) => { | ||
const { origin, path, querystring } = ctx.request | ||
@@ -3,0 +3,0 @@ const op = `${origin}${path}` |
{ | ||
"name": "koa-lowercase", | ||
"description": "Simple lowercasing middleware for Koa 2.", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"author": { | ||
@@ -32,9 +32,8 @@ "name": "Zac Anger", | ||
"babel-plugin-transform-es2015-modules-commonjs": "6.24.1", | ||
"babel-preset-babili": "0.1.1", | ||
"babel-preset-env": "1.5.1" | ||
"babel-preset-latest-minimal": "1.1.2" | ||
}, | ||
"engines": { | ||
"node": ">=6.7.0" | ||
"node": ">=7.6.0" | ||
}, | ||
"typings": "koa-lowercase.d.ts" | ||
} |
Sorry, the diff of this file is not supported yet
6314
3
47