Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: encode added routes #973

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/h3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,16 @@ class _H3 implements H3 {
}
const _method = (method || "").toUpperCase();
const _handler = (handler as H3)?.handler || handler;
addRoute(this._router, _method, route, <H3Route>{
method: _method,
route,
handler: _handler,
});
addRoute(
this._router,
_method,
new URL(route, "http://localhost").pathname,
<H3Route>{
method: _method,
route,
handler: _handler,
},
);
return this;
}

Expand Down
7 changes: 7 additions & 0 deletions test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ describeMatrix("app", (t, { it, expect }) => {
expect(await res.text()).toBe("valid");
});

it("can add arabic routes", async () => {
t.app.get("/عربي", () => "valid");

const res = await t.fetch("/عربي");
expect(res.status).toBe(200);
});

it.skipIf(t.target !== "node")(
"wait for node middleware (req, res, next)",
async () => {
Expand Down
Loading