Skip to content
Myr

fix(context): set the values of already set (#834)

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

authored by Yusuke Wada · committed by GitHub · parent a60e46a · Browse files · 4 files+30 added−0 removed
This commit

State

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

Diff stats

4 files+30 added−0 removed

  • tests:+20 added−0 removed
  • other:+10 added−0 removed

4 files+30 added−0 removed

modified:deno_dist/context.ts+5 added
63 unmodified lines
64 return (this._res ||= new Response('404 Not Found', { status: 404 }))65 }6667 set res(_res: Response) {68 if (this._res) {69 this._res.headers.forEach((v, k) => {70 _res.headers.set(k, v)71 })72 }73 this._res = _res74 this.finalized = true75 }76
173 unmodified lines
modified:src/middleware/cors/index.test.ts+12 added
modified:src/context.test.ts+8 added
119 unmodified lines
120 expect(c.res.headers.get('X-Custom4')).toBe('Message4')121 expect(c.res.status).toBe(201)122 })123124 it('Should append the previous headers to new Response', () => {125 c.res.headers.set('x-Custom1', 'Message1')126 const res2 = new Response('foo2')127 res2.headers.set('x-Custom2', 'Message2')128 c.res = res2129 expect(c.res.headers.get('x-Custom1')).toBe('Message1')130 })131132 it('Should return 200 response', async () => {133 const res = c.text('Text')134 expect(res.status).toBe(200)135 })
60 unmodified lines
modified:src/context.ts+5 added
63 unmodified lines
64 return (this._res ||= new Response('404 Not Found', { status: 404 }))65 }6667 set res(_res: Response) {68 if (this._res) {69 this._res.headers.forEach((v, k) => {70 _res.headers.set(k, v)71 })72 }73 this._res = _res74 this.finalized = true75 }76
173 unmodified lines