Skip to content
Open
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
12 changes: 11 additions & 1 deletion packages/socket.io/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import type { Socket as RawSocket } from "engine.io";

const debug = debugModule("socket.io:client");

function objectFromEntries(
entries: Iterable<readonly [PropertyKey, string]>,
): Record<string, string> {
const obj: Record<string, string> = Object.create(null);
for (const [key, value] of entries) {
obj[key as string] = value;
}
return obj;
}

interface WriteOptions {
compress?: boolean;
volatile?: boolean;
Expand Down Expand Up @@ -296,7 +306,7 @@ export class Client<
const url = new URL(packet.nsp, "https://socket.io");
return {
namespace: url.pathname,
authPayload: Object.fromEntries(url.searchParams.entries()),
authPayload: objectFromEntries(url.searchParams.entries()),
};
}

Expand Down