mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
fc3f19ef93
commit
eed1d33c53
1 changed files with 2 additions and 2 deletions
|
@ -93,8 +93,8 @@ function isLoopback(host) {
|
|||
return (
|
||||
hostLower === 'localhost' ||
|
||||
hostLower.startsWith('127.') ||
|
||||
hostLower.startsWith('[::1]') ||
|
||||
hostLower.startsWith('[0:0:0:0:0:0:0:1]')
|
||||
hostLower === '[::1]' ||
|
||||
hostLower === '[0:0:0:0:0:0:0:1]'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue