Skip to content

Commit 50aebad

Browse files
refactor: use native URL instead of url.parse
1 parent e95f6ab commit 50aebad

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/socket.io/lib/client.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Decoder, Encoder, Packet, PacketType } from "socket.io-parser";
22
import debugModule = require("debug");
3-
import url = require("url");
43
import type { IncomingMessage } from "http";
54
import type { Server } from "./index";
65
import type { Namespace } from "./namespace";
@@ -269,9 +268,9 @@ export class Client<
269268
let namespace: string;
270269
let authPayload: Record<string, unknown>;
271270
if (this.conn.protocol === 3) {
272-
const parsed = url.parse(packet.nsp, true);
271+
const parsed = new URL(packet.nsp, "https://socket.io");
273272
namespace = parsed.pathname!;
274-
authPayload = parsed.query;
273+
authPayload = Object.fromEntries(parsed.searchParams.entries());
275274
} else {
276275
namespace = packet.nsp;
277276
authPayload = packet.data;

0 commit comments

Comments
 (0)