File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -267,16 +267,7 @@ export class Client<
267267 * @private
268268 */
269269 private ondecoded ( packet : Packet ) : void {
270- let namespace : string ;
271- let authPayload : Record < string , unknown > ;
272- if ( this . conn . protocol === 3 ) {
273- const parsed = url . parse ( packet . nsp , true ) ;
274- namespace = parsed . pathname ! ;
275- authPayload = parsed . query ;
276- } else {
277- namespace = packet . nsp ;
278- authPayload = packet . data ;
279- }
270+ const { namespace, authPayload } = this . _parseNamespace ( packet ) ;
280271 const socket = this . nsps . get ( namespace ) ;
281272
282273 if ( ! socket && packet . type === PacketType . CONNECT ) {
@@ -295,6 +286,20 @@ export class Client<
295286 }
296287 }
297288
289+ private _parseNamespace ( packet : Packet ) {
290+ if ( this . conn . protocol !== 3 ) {
291+ return {
292+ namespace : packet . nsp ,
293+ authPayload : packet . data ,
294+ } ;
295+ }
296+ const url = new URL ( packet . nsp , "https://socket.io" ) ;
297+ return {
298+ namespace : url . pathname ,
299+ authPayload : Object . fromEntries ( url . searchParams . entries ( ) ) ,
300+ } ;
301+ }
302+
298303 /**
299304 * Handles an error.
300305 *
You can’t perform that action at this time.
0 commit comments