Skip to content
Myr

feat: allow pathname argument (#921)

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

* feat: allow pathname argument * fix: add control input argument * denoify

authored by hagishi · committed by GitHub · parent 17755d8 · Browse files · 3 files+32 added−3 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+32 added−3 removed

  • tests:+22 added−1 removed
  • other:+10 added−2 removed

3 files+32 added−3 removed

modified:deno_dist/hono.ts+5 added-1 removed
261 unmodified lines
262 return this.dispatch(request, executionCtx, Env)263 }264265 request = async (input: Request | string, requestInit?: RequestInit) => {266 const req = input instanceof Request ? input : new Request(input, requestInit)266 if (input instanceof Request) {267 return await this.fetch(input)268 }269 const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath('/', input)}`270 const req = new Request(path, requestInit)271 return await this.fetch(req)272 }273}
modified:src/hono.test.ts+22 added-1 removed
28 unmodified lines
29 c.status(201)30 return c.html('<h1>Hono!!!</h1>')31 })3233 it('GET /hello is ok', async () => {33 it('GET http://localhost/hello is ok', async () => {34 const res = await app.request('http://localhost/hello')35 expect(res).not.toBeNull()36 expect(res.status).toBe(200)37 expect(res.statusText).toBe('Hono is OK')38 expect(await res.text()).toBe('hello')39 })4041 it('GET httphello is ng', async () => {42 const res = await app.request('httphello')43 expect(res.status).toBe(404)44 })4546 it('GET /hello is ok', async () => {47 const res = await app.request('/hello')48 expect(res).not.toBeNull()49 expect(res.status).toBe(200)50 expect(res.statusText).toBe('Hono is OK')51 expect(await res.text()).toBe('hello')52 })5354 it('GET hello is ok', async () => {55 const res = await app.request('hello')56 expect(res).not.toBeNull()57 expect(res.status).toBe(200)58 expect(res.statusText).toBe('Hono is OK')59 expect(await res.text()).toBe('hello')60 })6162 it('GET /hello-with-shortcuts is ok', async () => {63 const res = await app.request('http://localhost/hello-with-shortcuts')64 expect(res).not.toBeNull()65 expect(res.status).toBe(201)
1659 unmodified lines
modified:src/hono.ts+5 added-1 removed
261 unmodified lines
262 return this.dispatch(request, executionCtx, Env)263 }264265 request = async (input: Request | string, requestInit?: RequestInit) => {266 const req = input instanceof Request ? input : new Request(input, requestInit)266 if (input instanceof Request) {267 return await this.fetch(input)268 }269 const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath('/', input)}`270 const req = new Request(path, requestInit)271 return await this.fetch(req)272 }273}