From 8be840e0a93c9c90565c6f137834ecacba0f14bf Mon Sep 17 00:00:00 2001 From: Al-phonsio <160236920+Al-phonsio@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:24:36 +0100 Subject: [PATCH] [doc] Replace `url.parse()` with `new URL()` (#2208) --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 80d988655..b6cacbe92 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,6 @@ server.listen(8080); ```js import { createServer } from 'http'; -import { parse } from 'url'; import { WebSocketServer } from 'ws'; const server = createServer(); @@ -265,7 +264,7 @@ wss2.on('connection', function connection(ws) { }); server.on('upgrade', function upgrade(request, socket, head) { - const { pathname } = parse(request.url); + const { pathname } = new URL(request.url, 'wss://base.url'); if (pathname === '/foo') { wss1.handleUpgrade(request, socket, head, function done(ws) {