Skip to content

Commit 4ceca85

Browse files
committed
refactor: avoid url.parse
1 parent 75d8e93 commit 4ceca85

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/_utils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import url from "node:url";
2-
31
const upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
42

53
/**
@@ -88,10 +86,9 @@ export function setupOutgoing(outgoing, options, req, forward?) {
8886
const targetPath =
8987
target && options.prependPath !== false ? target.path || "" : "";
9088

91-
//
92-
// Remark: Can we somehow not use url.parse as a perf optimization?
93-
//
94-
let outgoingPath = options.toProxy ? req.url : url.parse(req.url).path || "";
89+
let outgoingPath = options.toProxy
90+
? req.url
91+
: new URL(req.url, "http://localhost").pathname || "";
9592

9693
//
9794
// Remark: ignorePath will just straight up ignore whatever the request's

0 commit comments

Comments
 (0)