lib: Fix unnecessary coercion in lib/net.js

This is the PR version of @skypjack's patch in #6627