Skip to content
Myr

fix: empty string is a valid header value (#1056)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* empty string is a valid header value * yarn denoify

authored by Alex Errant · committed by GitHub · parent f077732 · Browse files · 3 files+12 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+12 added−4 removed

  • tests:+8 added−0 removed
  • other:+4 added−4 removed

3 files+12 added−4 removed

modified:deno_dist/request.ts+2 added-2 removed
modified:src/request.test.ts+8 added
66 unmodified lines
67 tag: ['sport', 'music'],68 })69 })70})7172describe('headers', () => {73 test('empty string is a valid header value', () => {74 const req = new HonoRequest(new Request('http://localhost', { headers: { foo: '' } }))75 const foo = req.header('foo')76 expect(foo).toEqual('')77 })78})
modified:src/request.ts+2 added-2 removed
67 unmodified lines
6869 header(name: string): string | undefined70 header(): Record<string, string>71 header(name?: string) {72 const headerData: Record<string, string> = {}72 const headerData: Record<string, string | undefined> = {}73 this.raw.headers.forEach((value, key) => {74 headerData[key] = value75 })76 if (!name) {77 return headerData78 }79 return headerData[name.toLowerCase()] || undefined79 return headerData[name.toLowerCase()]80 }8182 cookie(key: string): string | undefined83 cookie(): Cookie
98 unmodified lines