Skip to content
Myr

fix(req): decode special chars in URL params (#1010)

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 188aea1 · Browse files · 2 files+16 added−5 removed
This commit

State

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

Diff stats

2 files+16 added−5 removed

  • tests:+14 added−3 removed
  • other:+2 added−2 removed

2 files+16 added−5 removed

modified:src/utils/url.ts+2 added-2 removed
modified:src/request.test.ts+14 added-3 removed
1import { HonoRequest } from './request'23describe('Query', () => {4 const rawRequest = new Request('http://localhost?page=2&tag=A&tag=B')5 const req = new HonoRequest(rawRequest)64 test('req.query() and req.queries()', () => {5 const rawRequest = new Request('http://localhost?page=2&tag=A&tag=B')6 const req = new HonoRequest(rawRequest)78 const page = req.query('page')9 expect(page).not.toBeUndefined()10 expect(page).toBe('2')11
6 unmodified lines
1819 const q2 = req.queries('q2')20 expect(q2).toBeUndefined()21 })2223 test('decode special chars', () => {24 const rawRequest = new Request('http://localhost?mail=framework%40hono.dev&tag=%401&tag=%402')25 const req = new HonoRequest(rawRequest)2627 const mail = req.query('mail')28 expect(mail).toBe('framework@hono.dev')2930 const tags = req.queries('tag')31 expect(tags).toEqual(['@1', '@2'])32 })33})3435describe('req.addValidatedData() and req.data()', () => {36 const rawRequest = new Request('http://localhost')
34 unmodified lines