Handle more reservedIP cases
Some checks failed
Build / Build NPM Project (push) Successful in 42s
Build / Publish Documentation (push) Failing after 4s
Build / Tag Version (push) Successful in 8s

This commit is contained in:
2025-07-21 18:45:11 -04:00
parent 5efb045f22
commit 2b12916246
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.26.10",
"version": "0.26.11",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -53,7 +53,7 @@ export function ipV6ToV4(ip: string) {
* @returns {boolean}
*/
export function reservedIp(ip: string): boolean {
if(ip == 'localhost') return true;
if(ip == 'localhost' || ip == '127.0.0.1') return true;
return /\b(10\.(?:[0-9]{1,3}\.){2}[0-9]{1,3})\b|\b(172\.(?:1[6-9]|2[0-9]|3[0-1])\.(?:[0-9]{1,3}\.)[0-9]{1,3})\b|\b(192\.168\.(?:[0-9]{1,3}\.)[0-9]{1,3})\b/.test(ip);
}