Skip to content

Commit 9f7ea9b

Browse files
authored
fix: Replace deprecated url.parse (#31845)
1 parent 0d7b8f1 commit 9f7ea9b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/extension/frontend.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {createServer} from "node:http";
55
import {createServer as createSecureServer} from "node:https";
66
import type {Socket} from "node:net";
77
import {posix} from "node:path";
8-
import {parse} from "node:url";
98
import bind from "bind-decorator";
109
import expressStaticGzip from "express-static-gzip";
1110
import finalhandler from "finalhandler";
@@ -157,10 +156,10 @@ export class Frontend extends Extension {
157156
@bind private onUpgrade(request: IncomingMessage, socket: Socket, head: Buffer): void {
158157
this.wss.handleUpgrade(request, socket, head, (ws) => {
159158
// biome-ignore lint/style/noNonNullAssertion: `Only valid for request obtained from Server`
160-
const {query} = parse(request.url!, true);
159+
const {searchParams} = new URL(request.url!, "http://localhost"); // dummy base, may not be absolute
161160
const authToken = settings.get().frontend.auth_token;
162161

163-
if (!authToken || authToken === query.token) {
162+
if (!authToken || authToken === searchParams.get("token")) {
164163
this.wss.emit("connection", ws, request);
165164
} else {
166165
ws.close(4401, "Unauthorized");

0 commit comments

Comments
 (0)