diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-08-18 17:37:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-18 15:37:39 +0000 |
commit | 558d2a098bd20b3031139e37b088345c766e0b4e (patch) | |
tree | a932d7f4130f18a5a50ef19e271abc8327ce83cd /ext/node/polyfills/http.ts | |
parent | 35a17f38f6b32fe73ee6ef6d48cc774ddce998bd (diff) |
fix(node/http): wrong `req.url` value (#25081)
This PR addresses a regression introduced in
https://github.com/denoland/deno/pull/25021 that would cause the
`req.url` parameter in Node's http server to always be a single
character instead of the expected value. The regression was caused by
effectively calling `.indexOf()` on an empty string and thus passing the
wrong index for slicing.
```js
"".indexOf("/") // -> -1
request.url.slice(-1) // effectively only giving us the last character
```
Fixes https://github.com/denoland/deno/issues/25080
Diffstat (limited to 'ext/node/polyfills/http.ts')
-rw-r--r-- | ext/node/polyfills/http.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 015a91816..920f3a5b0 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1781,7 +1781,8 @@ export class ServerImpl extends EventEmitter { }); const req = new IncomingMessageForServer(socket); - req.url = request.url?.slice(req.url.indexOf("/", 8)); + // Slice off the origin so that we only have pathname + search + req.url = request.url?.slice(request.url.indexOf("/", 8)); req.method = request.method; req.upgrade = request.headers.get("connection")?.toLowerCase().includes("upgrade") && |