Skip to content

Commit 6e7bd5e

Browse files
committed
fix: endpoint URL parsing with extra dots and slashes
1 parent 0c5019b commit 6e7bd5e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class RPCServer extends EventEmitter {
8686
const ac = new AbortController();
8787
const {signal} = ac;
8888

89-
const url = new URL(request.url, 'http://localhost');
89+
const url = new URL('http://localhost' + (request.url || '/'));
9090
const pathParts = url.pathname.split('/');
9191
const identity = decodeURIComponent(pathParts.pop());
9292

@@ -129,7 +129,7 @@ class RPCServer extends EventEmitter {
129129
throw new WebsocketUpgradeError(400, "Can only upgrade websocket upgrade requests");
130130
}
131131

132-
const endpoint = pathParts.join('/');
132+
const endpoint = pathParts.join('/') || '/';
133133
const remoteAddress = request.socket.remoteAddress;
134134
const protocols = ('sec-websocket-protocol' in request.headers)
135135
? parseSubprotocols(request.headers['sec-websocket-protocol'])

0 commit comments

Comments
 (0)