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 {
276276 return this . modelNameMapping [ modelName ] ?? modelName ;
277277 }
278278
279- private matchUrlPattern ( path : string , routeType : UrlPatterns ) : Match {
279+ private matchUrlPattern ( path : string , routeType : UrlPatterns ) : Match | undefined {
280280 const pattern = this . urlPatternMap [ routeType ] ;
281281 if ( ! pattern ) {
282282 throw new InvalidValueError ( `Unknown route type: ${ routeType } ` ) ;
283283 }
284284
285285 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 ] ;
288292 }
293+
289294 return match ;
290295 }
291296
Original file line number Diff line number Diff line change @@ -3038,8 +3038,8 @@ describe('REST server tests', () => {
30383038 const _handler = makeHandler ( {
30393039 endpoint : 'http://localhost/api' ,
30403040 modelNameMapping : {
3041- myUser : 'user ' ,
3042- myPost : 'post ' ,
3041+ user : 'myUser ' ,
3042+ post : 'myPost ' ,
30433043 } ,
30443044 } ) ;
30453045 handler = ( args ) =>
You can’t perform that action at this time.
0 commit comments