account for :params and * wildcards in complex route match

This commit is contained in:
garrettmills 2020-07-29 23:25:30 -05:00
parent 0e5a0a5a5c
commit 42e8b36df4
No known key found for this signature in database
GPG Key ID: 6ACD58D6ADACFC6E
3 changed files with 8 additions and 2 deletions

6
.env Normal file
View File

@ -0,0 +1,6 @@
DATON_LOGGING_LEVEL=6
APP_NAME="My First Daton App!"
DB_USERNAME=garrettmills
DB_PASSWORD=garrettmills
DB_DATABASE=garrettmills

View File

@ -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))

View File

@ -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()
})
}