lib: use bracket notation instead of startsWith/endsWith for single char

Signed-off-by: Taejin Kim <rlaxowls1316@naver.com>
PR-URL: https://github.com/nodejs/node/pull/61500
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Taejin Kim authored and Antoine du Hamel committed 2026-09-07 11:53:57 +02:00
1 parent 774f663c56
commit 6bf852197d
1 file changed
+1 -1
+1 -1
View File
@@ -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,