From 6bf852197d64aa2b05b10fc2fa3fb6f6bed46c56 Mon Sep 17 00:00:00 2001 From: Taejin Kim <60560836+kimtaejin3@users.noreply.github.com> Date: Sun, 23 Aug 2026 11:39:25 +0900 Subject: [PATCH] lib: use bracket notation instead of startsWith/endsWith for single char Signed-off-by: Taejin Kim PR-URL: https://github.com/nodejs/node/pull/61500 Reviewed-By: Colin Ihrig Reviewed-By: Jordan Harband Reviewed-By: Luigi Pinca Reviewed-By: Yagiz Nizipli Reviewed-By: Trivikram Kamat --- lib/internal/socketaddress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/socketaddress.js b/lib/internal/socketaddress.js index 724ffd90cf7..28696d6cc87 100644 --- a/lib/internal/socketaddress.js +++ b/lib/internal/socketaddress.js @@ -157,7 +157,7 @@ class SocketAddress { hostname: address, port, } = URLParse(`http://${input}`); - if (address.startsWith('[') && address.endsWith(']')) { + if (address[0] === '[' && address[address.length - 1] === ']') { return new SocketAddress({ address: address.slice(1, -1), port: port | 0,