File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -276,16 +276,21 @@ class RequestHandler extends APIHandlerBase {
276
276
return this . modelNameMapping [ modelName ] ?? modelName ;
277
277
}
278
278
279
- private matchUrlPattern ( path : string , routeType : UrlPatterns ) : Match {
279
+ private matchUrlPattern ( path : string , routeType : UrlPatterns ) : Match | undefined {
280
280
const pattern = this . urlPatternMap [ routeType ] ;
281
281
if ( ! pattern ) {
282
282
throw new InvalidValueError ( `Unknown route type: ${ routeType } ` ) ;
283
283
}
284
284
285
285
const match = pattern . match ( path ) ;
286
- if ( match ) {
287
- match . type = this . reverseModelNameMapping [ match . type ] ?? match . type ;
286
+ if ( ! match || match . type in Object . keys ( this . modelNameMapping ) ) {
287
+ return ;
288
+ }
289
+
290
+ if ( match . type in this . reverseModelNameMapping ) {
291
+ match . type = this . reverseModelNameMapping [ match . type ] ;
288
292
}
293
+
289
294
return match ;
290
295
}
291
296
Original file line number Diff line number Diff line change @@ -3038,8 +3038,8 @@ describe('REST server tests', () => {
3038
3038
const _handler = makeHandler ( {
3039
3039
endpoint : 'http://localhost/api' ,
3040
3040
modelNameMapping : {
3041
- myUser : 'user ' ,
3042
- myPost : 'post ' ,
3041
+ user : 'myUser ' ,
3042
+ post : 'myPost ' ,
3043
3043
} ,
3044
3044
} ) ;
3045
3045
handler = ( args ) =>
You can’t perform that action at this time.
0 commit comments