Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #2208

Merged
merged 2 commits into from Mar 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 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,8 @@ wss2.on('connection', function connection(ws) {
});

server.on('upgrade', function upgrade(request, socket, head) {
const { pathname } = parse(request.url);
const baseURL = request.protocol + '://' + request.headers.host + '/';
const { pathname } = new URL(request.url, baseURL);
lpinca marked this conversation as resolved.
Show resolved Hide resolved

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