From 42e8b36df476e72c793217801417ec2272762207 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 29 Jul 2020 23:25:30 -0500 Subject: [PATCH] account for :params and * wildcards in complex route match --- .env | 6 ++++++ lib/src/http/ApiController.ts | 2 -- lib/src/http/routing/ComplexRoute.ts | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..50326d8 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +DATON_LOGGING_LEVEL=6 +APP_NAME="My First Daton App!" + +DB_USERNAME=garrettmills +DB_PASSWORD=garrettmills +DB_DATABASE=garrettmills diff --git a/lib/src/http/ApiController.ts b/lib/src/http/ApiController.ts index 2642316..5419ff9 100644 --- a/lib/src/http/ApiController.ts +++ b/lib/src/http/ApiController.ts @@ -26,8 +26,6 @@ export default class ApiController extends Controller { return result } - console.log('result', result) - // Otherwise, try to package the results as an API response if ( Array.isArray(result) ) { return this.make(JSONResponseFactory, api.many(result)) diff --git a/lib/src/http/routing/ComplexRoute.ts b/lib/src/http/routing/ComplexRoute.ts index 143771f..d1bbb95 100644 --- a/lib/src/http/routing/ComplexRoute.ts +++ b/lib/src/http/routing/ComplexRoute.ts @@ -10,6 +10,8 @@ export class ComplexRoute extends Route { if ( base_parts.length !== incoming_parts.length ) return false return base_parts.every((base, idx) => { + if ( base.startsWith(':') && base.length > 1 ) return true + else if ( base === '*' ) return true return base.toLowerCase() === incoming_parts[idx].toLowerCase() }) }