Skip to content

Commit

Permalink
Add getBooleanValue
Browse files Browse the repository at this point in the history
  • Loading branch information
kawarimidoll committed Jan 11, 2021
1 parent af12ef6 commit ea4ba8a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export class CustomURLSearchParams extends URLSearchParams {
}
return defaultValue;
}
getBooleanValue(key: string, defaultValue: boolean): boolean {
if (super.has(key)) {
const param = super.get(key);
return param !== null && param.toString() === 'true';
}
return defaultValue;
}
}

export function parseParams(req: ServerRequest): CustomURLSearchParams {
Expand Down

0 comments on commit ea4ba8a

Please sign in to comment.