Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3c4541f

Browse filesBrowse files
pckrishnadas88richardlau
authored andcommitted
lib: simplify IPv6 checks in isLoopback()
The checks for '[::1]' and '[0:0:0:0:0:0:0:1]' in isLoopback were using startsWith, which is unnecessary as these are canonical loopback addresses with no valid prefixes. Switching to strict equality improves clarity and improves performance. PR-URL: #59375 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
1 parent 77682b5 commit 3c4541f
Copy full SHA for 3c4541f

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/net.js‎

Copy file name to clipboardExpand all lines: lib/internal/net.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ function isLoopback(host) {
7979
return (
8080
hostLower === 'localhost' ||
8181
hostLower.startsWith('127.') ||
82-
hostLower.startsWith('[::1]') ||
83-
hostLower.startsWith('[0:0:0:0:0:0:0:1]')
82+
hostLower === '[::1]' ||
83+
hostLower === '[0:0:0:0:0:0:0:1]'
8484
);
8585
}
8686

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.