@@ -252,35 +252,36 @@ export function parseDiscoveredEndpoints(instances: string[]): Address[] {
252252
253253 const portStr = remainder . startsWith ( ":" ) ? remainder . slice ( 1 ) : "" ;
254254 const parsedPort = parsePortValue ( portStr ) ;
255- if ( parsedPort === null && portStr . length > 0 ) {
255+ if ( parsedPort === null ) {
256256 warnInvalidEndpoint ( raw ) ;
257257 continue ;
258258 }
259259 endpoints . push (
260- new Address ( `[${ ipv6Host } ]` , parsedPort ?? getDefaultPortForHost ( ipv6Host ) )
260+ new Address ( `[${ ipv6Host } ]` , parsedPort )
261261 ) ;
262262 continue ;
263263 }
264264
265- let host = trimmed ;
266- let port = getDefaultPortForHost ( host ) ;
267265 const lastColon = trimmed . lastIndexOf ( ":" ) ;
268- if ( lastColon !== - 1 ) {
269- host = trimmed . slice ( 0 , lastColon ) ;
270- if ( host . length === 0 || host . includes ( ":" ) ) {
271- warnInvalidEndpoint ( raw ) ;
272- continue ;
273- }
274- const portStr = trimmed . slice ( lastColon + 1 ) ;
275- const parsedPort = parsePortValue ( portStr ) ;
276- if ( parsedPort === null && portStr . length > 0 ) {
277- warnInvalidEndpoint ( raw ) ;
278- continue ;
279- }
280- port = parsedPort ?? getDefaultPortForHost ( host ) ;
266+ if ( lastColon === - 1 ) {
267+ warnInvalidEndpoint ( raw ) ;
268+ continue ;
269+ }
270+
271+ const host = trimmed . slice ( 0 , lastColon ) ;
272+ if ( host . length === 0 || host . includes ( ":" ) ) {
273+ warnInvalidEndpoint ( raw ) ;
274+ continue ;
275+ }
276+
277+ const portStr = trimmed . slice ( lastColon + 1 ) ;
278+ const parsedPort = parsePortValue ( portStr ) ;
279+ if ( parsedPort === null ) {
280+ warnInvalidEndpoint ( raw ) ;
281+ continue ;
281282 }
282283
283- endpoints . push ( new Address ( host , port ) ) ;
284+ endpoints . push ( new Address ( host , parsedPort ) ) ;
284285 }
285286 return endpoints ;
286287}
0 commit comments