account for :params and * wildcards in complex route match
This commit is contained in:
parent
0e5a0a5a5c
commit
42e8b36df4
6
.env
Normal file
6
.env
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
DATON_LOGGING_LEVEL=6
|
||||||
|
APP_NAME="My First Daton App!"
|
||||||
|
|
||||||
|
DB_USERNAME=garrettmills
|
||||||
|
DB_PASSWORD=garrettmills
|
||||||
|
DB_DATABASE=garrettmills
|
@ -26,8 +26,6 @@ export default class ApiController extends Controller {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('result', result)
|
|
||||||
|
|
||||||
// Otherwise, try to package the results as an API response
|
// Otherwise, try to package the results as an API response
|
||||||
if ( Array.isArray(result) ) {
|
if ( Array.isArray(result) ) {
|
||||||
return this.make(JSONResponseFactory, api.many(result))
|
return this.make(JSONResponseFactory, api.many(result))
|
||||||
|
@ -10,6 +10,8 @@ export class ComplexRoute extends Route {
|
|||||||
if ( base_parts.length !== incoming_parts.length ) return false
|
if ( base_parts.length !== incoming_parts.length ) return false
|
||||||
|
|
||||||
return base_parts.every((base, idx) => {
|
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()
|
return base.toLowerCase() === incoming_parts[idx].toLowerCase()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user