Skip to content

Commit 8410ec9

Browse files
pi0claude
andcommitted
test(event): assert req.url reflects normalization per runtime
On node srvx derives req.url from the shared _url so the decoded pathname shows through; on web Request.url keeps the wire encoding. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 4a218a8 commit 8410ec9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

test/event.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,21 @@ describeMatrix("event", (t, { it, expect }) => {
9696
it("normalizes percent-encoded pathname and syncs the raw node url", async () => {
9797
t.app.all("/*", (event) => ({
9898
pathname: event.url.pathname,
99+
reqUrl: event.req.url,
99100
rawNodeUrl: event.runtime?.node?.req?.url ?? null,
100101
}));
101102
const res = await t.fetch("/h%65llo?q=%41");
102103
const body = await res.json();
103104
expect(body.pathname).toBe("/hello");
104105
if (t.target === "node") {
105-
// srvx NodeRequestURL writes pathname mutations back to the raw
106-
// Node request; the search string must stay untouched
106+
// srvx derives req.url from the shared _url, so the normalization
107+
// shows through, and NodeRequestURL writes pathname mutations back
108+
// to the raw Node request; the search string must stay untouched
109+
expect(new URL(body.reqUrl).pathname).toBe("/hello");
107110
expect(body.rawNodeUrl).toBe("/hello?q=%41");
108111
} else {
112+
// web Request.url is an immutable string and keeps the wire encoding
113+
expect(new URL(body.reqUrl).pathname).toBe("/h%65llo");
109114
expect(body.rawNodeUrl).toBe(null);
110115
}
111116
});

0 commit comments

Comments
 (0)