Skip to content

Commit

Permalink
fix(server): changes per review
Browse files Browse the repository at this point in the history
  • Loading branch information
dethell committed Apr 10, 2024
1 parent d0f6f5a commit d9fa14f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/server/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ export class Dispatcher {
path: string,
method: HttpMethods,
): OpenApiOperation | undefined {
for (const key in this.openApiDocument?.paths) {
if (key.toLowerCase() === path.toLowerCase()) {
return this.openApiDocument.paths[key]?.[
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
method.toLowerCase() as Lowercase<HttpMethods>
];
break;
if (this.openApiDocument) {
for (const key in this.openApiDocument.paths) {
if (key.toLowerCase() === path.toLowerCase()) {
return this.openApiDocument.paths[key]?.[
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
method.toLowerCase() as Lowercase<HttpMethods>
];
}
}
}

Expand Down
15 changes: 14 additions & 1 deletion test/server/dispatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ describe("given a request that contains the differently cased path", () => {
},
});

const response = await dispatcher.request({
let response = await dispatcher.request({
body: "",
headers: {},
method: "POST",
Expand All @@ -864,5 +864,18 @@ describe("given a request that contains the differently cased path", () => {
expect(response.status).toBe(200);

expect(response.body).toBe("ok");

response = await dispatcher.request({
body: "",
headers: {},
method: "POST",
path: "/ABC",
query: {},
req: { path: "/ABC" },
});

expect(response.status).toBe(200);

expect(response.body).toBe("ok");
});
});

0 comments on commit d9fa14f

Please sign in to comment.