Skip to content

Commit 0315956

Browse files
author
vhess
committed
ts: check for href before use
1 parent 697d838 commit 0315956

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/http-proxy/common.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,18 @@ export function setupOutgoing(
150150
if (options.changeOrigin) {
151151
outgoing.headers.host =
152152
target.protocol !== undefined &&
153-
required(outgoing.port, target.protocol) &&
154-
!hasPort(outgoing.host)
153+
required(outgoing.port, target.protocol) &&
154+
!hasPort(outgoing.host)
155155
? outgoing.host + ":" + outgoing.port
156156
: outgoing.host;
157157
}
158158

159-
outgoing.url =
160-
target.href ||
159+
outgoing.url = ("href" in target &&
160+
target.href) ||
161161
(target.protocol === "https" ? "https" : "http") +
162-
"://" +
163-
outgoing.host +
164-
(outgoing.port ? ":" + outgoing.port : "");
162+
"://" +
163+
outgoing.host +
164+
(outgoing.port ? ":" + outgoing.port : "");
165165

166166
if (req.httpVersionMajor > 1) {
167167
for (const header of HTTP2_HEADER_BLACKLIST) {

0 commit comments

Comments
 (0)