Skip to content
Myr

fix(hono-base): enable `strict` with `getPath` option (#1259)

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

* fix(hono-base): enable `strict` with `getPath` option * denoify

authored by Yusuke Wada · committed by GitHub · parent ba346a4 · Browse files · 3 files+22 added−2 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+22 added−2 removed

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

3 files+22 added−2 removed

modified:deno_dist/hono-base.ts+1 added-1 removed
120 unmodified lines
121122 const strict = init.strict ?? true123 delete init.strict124 Object.assign(this, init)125 this.getPath ||= strict ? getPath : getPathNoStrict125 this.getPath = strict ? init.getPath ?? getPath : getPathNoStrict126 }127128 private clone(): Hono<E, S, BasePath> {129 const clone = new Hono<E, S, BasePath>({
254 unmodified lines
modified:src/hono-base.ts+1 added-1 removed
120 unmodified lines
121122 const strict = init.strict ?? true123 delete init.strict124 Object.assign(this, init)125 this.getPath ||= strict ? getPath : getPathNoStrict125 this.getPath = strict ? init.getPath ?? getPath : getPathNoStrict126 }127128 private clone(): Hono<E, S, BasePath> {129 const clone = new Hono<E, S, BasePath>({
254 unmodified lines
modified:src/hono.test.ts+20 added
140 unmodified lines
141 expect(res).not.toBeNull()142 expect(res.status).toBe(200)143 })144 })145146 describe('strict is false with `getPath` option', () => {147 const app = new Hono({148 strict: false,149 getPath: getPath,150 })151152 app.get('/hello', (c) => {153 return c.text('/hello')154 })155156 it('/hello and /hello/ are treated as the same', async () => {157 let res = await app.request('http://localhost/hello')158 expect(res).not.toBeNull()159 expect(res.status).toBe(200)160 res = await app.request('http://localhost/hello/')161 expect(res).not.toBeNull()162 expect(res.status).toBe(200)163 })164 })165})166167describe('Destruct functions in context', () => {168 it('Should return 200 response - text', async () => {
2003 unmodified lines