appolo-route
Advanced tools
Comparing version 6.0.3 to 6.0.4
@@ -17,2 +17,3 @@ "use strict"; | ||
this._paramNamesFull = keyFull.map(item => item.name); | ||
this._isAny = part == "*"; | ||
} | ||
@@ -24,6 +25,6 @@ check(parts, index, params) { | ||
let part = parts[index]; | ||
if (this._leafs.length == 0 && this._handler) { | ||
return this._checkFullPath(index, parts, params); | ||
} | ||
let regexMatch = this._regex.exec(part); | ||
// if(this._leafs.length == 0 && this._handler){ | ||
// return this._checkFullPath(index,parts,params) | ||
// } | ||
let regexMatch = this._isAny ? [] : this._regex.exec(part); | ||
if (!regexMatch) { | ||
@@ -54,2 +55,5 @@ return null; | ||
_addParams(params, keys, values) { | ||
if (!values.length) { | ||
return; | ||
} | ||
let decode = this._options.decodeUrlParams; | ||
@@ -56,0 +60,0 @@ for (let i = 0, len = keys.length; i < len; i++) { |
@@ -1,6 +0,6 @@ | ||
import {LeafType, Methods} from "./enums"; | ||
import {LeafType} from "./enums"; | ||
import {Leaf, Params} from "./leaf"; | ||
import {Util} from "./util"; | ||
import pathToRegexp = require('path-to-regexp') | ||
import {IOptions} from "./IOptions"; | ||
import pathToRegexp = require('path-to-regexp'); | ||
@@ -13,7 +13,8 @@ export class RegexLeaf extends Leaf { | ||
private _paramNamesFull: string[]; | ||
private _isAny: boolean; | ||
public readonly Type = LeafType.Regex; | ||
constructor(part: string,parts:string[],index:number,options:IOptions) { | ||
super(part,options); | ||
constructor(part: string, parts: string[], index: number, options: IOptions) { | ||
super(part, options); | ||
@@ -29,5 +30,8 @@ let keys = [], keyFull = []; | ||
this._paramNames = keys.map(item => item.name); | ||
this._paramNamesFull = keyFull.map(item => item.name); } | ||
this._paramNamesFull = keyFull.map(item => item.name); | ||
this._isAny = part == "*"; | ||
} | ||
public check(parts: string[], index: number, params: Params): Leaf { | ||
@@ -42,7 +46,7 @@ | ||
if(this._leafs.length == 0 && this._handler){ | ||
return this._checkFullPath(index,parts,params) | ||
} | ||
// if(this._leafs.length == 0 && this._handler){ | ||
// return this._checkFullPath(index,parts,params) | ||
// } | ||
let regexMatch = this._regex.exec(part); | ||
let regexMatch = this._isAny ? [] :this._regex.exec(part); | ||
@@ -58,3 +62,3 @@ if (!regexMatch) { | ||
let found = this._checkLeafs(parts, index, params); | ||
let found = this._checkLeafs(parts, index, params); | ||
@@ -67,3 +71,3 @@ if (found) { | ||
if (regexMatch && this._handler) { | ||
return this._checkFullPath(index,parts,params) | ||
return this._checkFullPath(index, parts, params) | ||
@@ -73,3 +77,3 @@ } | ||
private _checkFullPath(index:number,parts:string[],params:Params):Leaf{ | ||
private _checkFullPath(index: number, parts: string[], params: Params): Leaf { | ||
let regexMatch = this._regexFull.exec(Util.joinByIndex(index, parts)); | ||
@@ -86,6 +90,8 @@ | ||
private _addParams(params: Params, keys: string[], values: string[]) { | ||
if(!values.length){ | ||
return; | ||
} | ||
let decode = this._options.decodeUrlParams; | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
params[keys[i]] = decode ? decodeURIComponent(values[i+1]) :values[i+1] | ||
params[keys[i]] = decode ? decodeURIComponent(values[i + 1]) : values[i + 1] | ||
} | ||
@@ -92,0 +98,0 @@ } |
@@ -22,3 +22,3 @@ { | ||
"main": "./index.js", | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"license": "MIT", | ||
@@ -25,0 +25,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46405
784