Skip to content

Commit 8be840e

Browse files
authored
[doc] Replace url.parse() with new URL() (#2208)
1 parent 5e42cfd commit 8be840e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ server.listen(8080);
245245

246246
```js
247247
import { createServer } from 'http';
248-
import { parse } from 'url';
249248
import { WebSocketServer } from 'ws';
250249

251250
const server = createServer();
@@ -265,7 +264,7 @@ wss2.on('connection', function connection(ws) {
265264
});
266265

267266
server.on('upgrade', function upgrade(request, socket, head) {
268-
const { pathname } = parse(request.url);
267+
const { pathname } = new URL(request.url, 'wss://base.url');
269268

270269
if (pathname === '/foo') {
271270
wss1.handleUpgrade(request, socket, head, function done(ws) {

0 commit comments

Comments
 (0)