type checker no trust functions as type guards

This commit is contained in:
RealBeepMcJeep 2023-08-30 09:14:46 -07:00
parent b648d9bd87
commit 398544407d
1 changed files with 1 additions and 1 deletions

View File

@ -385,7 +385,7 @@ function getIpFromRequest(req) {
let clientIp = req.connection.remoteAddress;
let ip = ipaddr.parse(clientIp);
// Check if the IP address is IPv4-mapped IPv6 address
if (ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) {
if (ip.kind() === 'ipv6' && ip instanceof ipaddr.IPv6 && ip.isIPv4MappedAddress()) {
const ipv4 = ip.toIPv4Address().toString();
clientIp = ipv4;
} else {