mirror of
https://github.com/nodejs/node.git
synced 2025-05-14 18:26:05 +00:00

PR-URL: https://github.com/nodejs/node/pull/35474 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
10 lines
271 B
JavaScript
10 lines
271 B
JavaScript
"use strict";
|
|
const {v4, v6} = require("cidr-regex");
|
|
|
|
const re4 = v4({exact: true});
|
|
const re6 = v6({exact: true});
|
|
|
|
module.exports = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);
|
|
module.exports.v4 = str => re4.test(str);
|
|
module.exports.v6 = str => re6.test(str);
|