Skip to content

Broken query params handling behavier on escaped character "%2B" (the "+" symbol) in 1.1.26 #943

Open
@kazkazma

Description

@kazkazma

What version of Elysia is running?

1.1.26

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

I found this issue when I tried parsing the ISO8601 string with a positive timezone.

The following reproduce code is a little bit diffrent from the test-case which is at

it('parse + in query', async () => {

import Elysia, { t } from "elysia";

const api = new Elysia().get("", ({ query }) => query, {
  query: t.Object({
    keyword: t.String(),
  }),
});

const url = new URL("http://localhost:3000/");
url.searchParams.append("keyword", "hello+world");
console.log(url.href);    // http://localhost:3000/?keyword=hello%2Bworld

const result = await api
  .handle(new Request(url.href))
  .then((response) => response.json());

console.log(result); 
/* 
{
  keyword: "hello world",    // Should be "hello+world"
}
*/

What is the expected behavior?

When sending the "%2B", should return "+"

What do you see instead?

As downgrading to 1.1.25, the behavier is as expected, which returns a "+".

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions