Skip to content

Commit

Permalink
fix(core): raw headers may be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Sep 28, 2024
1 parent f1ec415 commit 9c37ad2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ export class HonoRequest<P extends string = '/', I extends Input['out'] = {}> {
header(): Record<string, string>
header(name?: string) {
if (name) {
return this.raw.headers.get(name.toLowerCase()) ?? undefined
return this.raw.headers?.get(name.toLowerCase()) ?? undefined
}

const headerData: Record<string, string | undefined> = {}
this.raw.headers.forEach((value, key) => {
this.raw.headers?.forEach((value, key) => {
headerData[key] = value
})
return headerData
Expand Down

0 comments on commit 9c37ad2

Please sign in to comment.