@@ -128,21 +128,25 @@ export class RateLimiterManager {
128128 public getRateLimiter ( ) : ( req : Request , res : Response , next : NextFunction ) => void {
129129 return ( req : Request , res : Response , next : NextFunction ) => {
130130 const id = req . params . id
131- // Ensure the id is valid and corresponds to an own, function-valued rate limiter
132- if ( typeof id !== 'string' || id . length === 0 ) return next ( )
133- if ( ! Object . prototype . hasOwnProperty . call ( this . rateLimiters , id ) ) return next ( )
134- const idRateLimiter = this . rateLimiters [ id ]
135- if ( typeof idRateLimiter !== 'function' ) return next ( )
136- return idRateLimiter ( req , res , next )
131+ if ( typeof id === 'string' && id . length > 0 && Object . prototype . hasOwnProperty . call ( this . rateLimiters , id ) ) {
132+ const idRateLimiter = this . rateLimiters [ id ] ;
133+ if ( typeof idRateLimiter === 'function' ) {
134+ return idRateLimiter ( req , res , next ) ;
135+ }
136+ }
137+ return next ( ) ;
137138 }
138139 }
139140
140141 public getRateLimiterById ( id : string ) : ( req : Request , res : Response , next : NextFunction ) => void {
141142 return ( req : Request , res : Response , next : NextFunction ) => {
142- if ( ! Object . prototype . hasOwnProperty . call ( this . rateLimiters , id ) ) return next ( )
143- const idRateLimiter = this . rateLimiters [ id ]
144- if ( typeof idRateLimiter !== 'function' ) return next ( )
145- return idRateLimiter ( req , res , next )
143+ if ( Object . prototype . hasOwnProperty . call ( this . rateLimiters , id ) ) {
144+ const idRateLimiter = this . rateLimiters [ id ] ;
145+ if ( typeof idRateLimiter === 'function' ) {
146+ return idRateLimiter ( req , res , next ) ;
147+ }
148+ }
149+ return next ( ) ;
146150 }
147151 }
148152
0 commit comments