Skip to content

Commit

Permalink
[doc] Replace url.parse() with new URL() (#2208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-phonsio committed Mar 16, 2024
1 parent 5e42cfd commit 8be840e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -245,7 +245,6 @@ server.listen(8080);

```js
import { createServer } from 'http';
import { parse } from 'url';
import { WebSocketServer } from 'ws';

const server = createServer();
Expand All @@ -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) {
Expand Down

0 comments on commit 8be840e

Please sign in to comment.