Skip to content

Commit 634d4c7

Browse files
committed
Simplify localhost IP detection
1 parent 597fa4d commit 634d4c7

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

web/src/server/free-mode-country.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ type FreeModeCountryAccessOptions = {
5959
allowLocalhost?: boolean
6060
}
6161

62-
const LOCALHOST_IPS = new Set(['127.0.0.1', '::1', '::ffff:127.0.0.1'])
62+
const LOCALHOST_IPS = new Set(['::1', '::ffff:127.0.0.1'])
6363

64-
function isLocalhostIp(ip: string | undefined): boolean {
65-
if (!ip) return false
66-
return LOCALHOST_IPS.has(ip) || ip.startsWith('127.')
64+
function isLocalhostIp(ip: string): boolean {
65+
return ip.startsWith('127.') || LOCALHOST_IPS.has(ip)
6766
}
6867

6968
type ResolvedCountryAccess = Omit<

0 commit comments

Comments
 (0)