Skip to content

Commit

Permalink
Fix unexpected parameter when query schema is empty object
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Mar 13, 2024
1 parent 6c8d721 commit b25775c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function OpenAPIRouter<
RequestType = IRequest,
Args extends any[] = any[],
RouteType = Equal<RequestType, IRequest> extends true
? Route
: UniversalRoute<RequestType, Args>
? Route
: UniversalRoute<RequestType, Args>
>(options?: RouterOptions): OpenAPIRouterType<RouteType, Args> {
const registry: OpenAPIRegistryMerger = new OpenAPIRegistryMerger()

Expand Down
8 changes: 7 additions & 1 deletion src/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,13 @@ export function extractQueryParameters(
): Record<string, any> | null {
const { searchParams } = new URL(request.url)

if (searchParams.size === 0) {
// For older node versions, searchParams is just an object without the size property
if (
searchParams.size === 0 ||
(searchParams.size === undefined &&
typeof searchParams === 'object' &&
Object.keys(searchParams).length === 0)
) {
return null
}

Expand Down

0 comments on commit b25775c

Please sign in to comment.