@koa/router 10.0.0 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/layer.js +5 -5
  2. package/package.json +1 -1
package/lib/layer.js CHANGED
@@ -24,9 +24,9 @@ function Layer(path, methods, middleware, opts) {
24
24
  this.paramNames = [];
25
25
  this.stack = Array.isArray(middleware) ? middleware : [middleware];
26
26
 
27
- for(let i = 0; i < methods.length; i++) {
27
+ for (let i = 0; i < methods.length; i++) {
28
28
  const l = this.methods.push(methods[i].toUpperCase());
29
- if (this.methods[l-1] === 'GET') this.methods.unshift('HEAD');
29
+ if (this.methods[l - 1] === 'GET') this.methods.unshift('HEAD');
30
30
  }
31
31
 
32
32
  // ensure middleware is a function
@@ -68,10 +68,10 @@ Layer.prototype.match = function (path) {
68
68
  Layer.prototype.params = function (path, captures, existingParams) {
69
69
  const params = existingParams || {};
70
70
 
71
- for (let len = captures.length, i=0; i<len; i++) {
71
+ for (let len = captures.length, i = 0; i < len; i++) {
72
72
  if (this.paramNames[i]) {
73
73
  const c = captures[i];
74
- params[this.paramNames[i].name] = c ? safeDecodeURIComponent(c) : c;
74
+ if (c && c.length !== 0) params[this.paramNames[i].name] = c ? safeDecodeURIComponent(c) : c;
75
75
  }
76
76
  }
77
77
 
@@ -125,7 +125,7 @@ Layer.prototype.url = function (params, options) {
125
125
  let replace = {};
126
126
 
127
127
  if (args instanceof Array) {
128
- for (let len = tokens.length, i=0, j=0; i<len; i++) {
128
+ for (let len = tokens.length, i = 0, j = 0; i < len; i++) {
129
129
  if (tokens[i].name) replace[tokens[i].name] = args[j++];
130
130
  }
131
131
  } else if (tokens.some(token => token.name)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@koa/router",
3
3
  "description": "Router middleware for koa. Provides RESTful resource routing.",
4
- "version": "10.0.0",
4
+ "version": "10.1.0",
5
5
  "author": "Alex Mingoia <talk@alexmingoia.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/koajs/router/issues",