File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { WebTransport } from "./transports/webtransport";
2121import { createPacketDecoderStream } from "engine.io-parser" ;
2222import type { EngineRequest , Transport } from "./transport" ;
2323import type { CookieSerializeOptions } from "./contrib/types.cookie" ;
24+ import { objectFromEntries } from "./utils/objectFromEntries" ;
2425
2526const debug = debugModule ( "engine" ) ;
2627
@@ -763,7 +764,7 @@ export class Server extends BaseServer {
763764 // try to leverage pre-existing `req._query` (e.g: from connect)
764765 if ( ! req . _query ) {
765766 const url = new URL ( req . url , "https://socket.io" ) ;
766- req . _query = Object . fromEntries ( url . searchParams . entries ( ) ) ;
767+ req . _query = objectFromEntries ( url . searchParams . entries ( ) ) ;
767768 }
768769 }
769770
Original file line number Diff line number Diff line change 1+ // polyfill for Node.js < 12
2+ // reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries
3+ export const objectFromEntries =
4+ Object . fromEntries ||
5+ function fromEntries < T = unknown > (
6+ entries : Iterable < readonly [ PropertyKey , T ] > ,
7+ ) : Record < PropertyKey , T > {
8+ const obj : Record < PropertyKey , T > = { } ;
9+
10+ for ( const [ key , value ] of entries ) {
11+ obj [ key ] = value ;
12+ }
13+
14+ return obj ;
15+ } ;
You can’t perform that action at this time.
0 commit comments