Skip to content

Commit

Permalink
Detect network address on Node 18
Browse files Browse the repository at this point in the history
In the output of `os.networkInterfaces()`, the `family` field in Node 18 has been changed from a string (`"IPv4"`) to an int (`4`). It’s an undocumented change ([there is an issue about it](nodejs/node#42787)) but it’s there in Node v18.1.0. 

This change supports both version of this field, improving compatibility.
  • Loading branch information
sylbru authored Dec 7, 2022
1 parent b877dd2 commit e01d5d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/utilities/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getNetworkAddress = (): string | undefined => {
for (const details of interfaceDetails) {
const { address, family, internal } = details;

if (family === 'IPv4' && !internal) return address;
if ((family === 'IPv4' || family === 4) && !internal) return address;
}
}
};

0 comments on commit e01d5d1

Please sign in to comment.