Skip to content

Commit ae62ab0

Browse files
committed
fixed sonar findigns
1 parent 8cad79a commit ae62ab0

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

packages/event-handler/src/rest/Router.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ class Router {
243243
);
244244
} else {
245245
const handler =
246-
options?.scope != null
247-
? route.handler.bind(options.scope)
248-
: route.handler;
246+
options?.scope == null
247+
? route.handler
248+
: route.handler.bind(options.scope);
249249

250250
const handlerResult = await handler(params, reqCtx);
251251
reqCtx.res = handlerResultToWebResponse(
@@ -286,12 +286,10 @@ class Router {
286286
public route(handler: RouteHandler, options: RestRouteOptions): void {
287287
const { method, path, middleware = [] } = options;
288288
const methods = Array.isArray(method) ? method : [method];
289-
const resolvedPath: Path =
290-
this.prefix === undefined
291-
? path
292-
: path === '/'
293-
? this.prefix
294-
: `${this.prefix}${path}`;
289+
let resolvedPath = path;
290+
if (this.prefix) {
291+
resolvedPath = path === '/' ? this.prefix : `${this.prefix}${path}`;
292+
}
295293

296294
for (const method of methods) {
297295
this.routeRegistry.register(

0 commit comments

Comments
 (0)