Skip to content

Commit

Permalink
fix additional entry inected to params ..
Browse files Browse the repository at this point in the history
  • Loading branch information
3imed-jaberi committed Jul 15, 2021
1 parent 344ba0b commit f2b95e9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ function Layer(path, methods, middleware, opts) {
this.paramNames = [];
this.stack = Array.isArray(middleware) ? middleware : [middleware];

for(let i = 0; i < methods.length; i++) {
for (let i = 0; i < methods.length; i++) {
const l = this.methods.push(methods[i].toUpperCase());
if (this.methods[l-1] === 'GET') this.methods.unshift('HEAD');
if (this.methods[l - 1] === 'GET') this.methods.unshift('HEAD');
}

// ensure middleware is a function
Expand Down Expand Up @@ -68,9 +68,10 @@ Layer.prototype.match = function (path) {
Layer.prototype.params = function (path, captures, existingParams) {
const params = existingParams || {};

for (let len = captures.length, i=0; i<len; i++) {
for (let len = captures.length, i = 0; i < len; i++) {
if (this.paramNames[i]) {
const c = captures[i];
if (c && c.length === 0) continue;
params[this.paramNames[i].name] = c ? safeDecodeURIComponent(c) : c;
}
}
Expand Down Expand Up @@ -125,7 +126,7 @@ Layer.prototype.url = function (params, options) {
let replace = {};

if (args instanceof Array) {
for (let len = tokens.length, i=0, j=0; i<len; i++) {
for (let len = tokens.length, i = 0, j = 0; i < len; i++) {
if (tokens[i].name) replace[tokens[i].name] = args[j++];
}
} else if (tokens.some(token => token.name)) {
Expand Down

0 comments on commit f2b95e9

Please sign in to comment.