File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ const {
6060const Agent = require ( '_http_agent' ) ;
6161const { Buffer } = require ( 'buffer' ) ;
6262const { defaultTriggerAsyncIdScope } = require ( 'internal/async_hooks' ) ;
63- const { URL , urlToHttpOptions, isURL } = require ( 'internal/url' ) ;
63+ const { URL , URLParse , urlToHttpOptions, isURL } = require ( 'internal/url' ) ;
6464const {
6565 kOutHeaders,
6666 kNeedDrain,
@@ -196,23 +196,18 @@ function authoritiesMatch(canonicalHost, hostFromHeader) {
196196
197197function isValidConnectPath ( path ) {
198198 const match = CONNECT_PATH_REGEX . exec ( path ) ;
199- if ( match === null ) {
199+ if ( match === null || + match [ 2 ] === 0 ) {
200200 return false ;
201201 }
202202
203- try {
204- validatePort ( match [ 2 ] , 'options.path' , false ) ;
205- const url = new URL ( `http://${ path } ` ) ;
206-
207- return url . hostname !== '' &&
208- url . username === '' &&
209- url . password === '' &&
210- url . pathname === '/' &&
211- url . search === '' &&
212- url . hash === '' ;
213- } catch {
214- return false ;
215- }
203+ const url = URLParse ( `http://${ path } ` ) ;
204+ return url !== null &&
205+ url . hostname !== '' &&
206+ url . username === '' &&
207+ url . password === '' &&
208+ url . pathname === '/' &&
209+ url . search === '' &&
210+ url . hash === '' ;
216211}
217212
218213// https://datatracker.ietf.org/doc/html/rfc9112#section-3.2
You can’t perform that action at this time.
0 commit comments