Make route extraction account for extraneous / matches

This commit is contained in:
Garrett Mills 2022-04-05 12:39:33 -05:00
parent 8b2ee1c949
commit 2e7c927114
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@extollo/lib",
"version": "0.9.30",
"version": "0.9.31",
"description": "The framework library that lifts up your code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

View File

@ -275,11 +275,11 @@ export class Route<TReturn extends ResponseObject, THandlerParams extends unknow
* @param potential
*/
public extract(potential: string): {[key: string]: string} | undefined {
const routeParts = (this.route.startsWith('/') ? this.route.substr(1) : this.route).split('/')
const potentialParts = (potential.startsWith('/') ? potential.substr(1) : potential).split('/')
const routeParts = (this.route.startsWith('/') ? this.route.substr(1) : this.route).split('/').filter(Boolean)
const potentialParts = (potential.startsWith('/') ? potential.substr(1) : potential).split('/').filter(Boolean)
Application.getApplication().make<Logging>(Logging)
.verbose(`Extracting route - (potential: ${potential}, rP: ${JSON.stringify(routeParts)}, pP: ${JSON.stringify(potentialParts)})`)
.trace(`Extracting route - (potential: ${potential}, rP: ${JSON.stringify(routeParts)}, pP: ${JSON.stringify(potentialParts)})`)
const params: any = {}
let wildcardIdx = 0