
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
local-hostname
Advanced tools
A tiny (171B) utility to check if a hostname is local
Compares an incoming URL hostname segment against a manually constructed RegExp pattern.
The pattern supports IPV4 and IPV6 addresses and is derived from RFC1918 – see Wikipedia explainer.
This module supports browser and Node.js environments.
It is made available in three formats:
dist/localhost.jsdist/localhost.mjsdist/localhost.min.js$ npm install --save local-hostname
import localhost from 'local-hostname';
localhost('localhost'); //=> true
localhost('127.0.254.1'); //=> true
localhost('hello.localhost'); //=> true
localhost('192.168.0.1'); //=> true
localhost('localhost.123'); //=> false
localhost('192.167.100.300'); //=> false
localhost('168.254.1.255'); //=> false
localhost('example.com'); //=> false
Returns: Boolean
Type: String
The hostname segment of a valid URL.
Important: The
localhostfunction does not parse or format the URL for you!
PRs are welcome, of course! However, please open an issue first to discuss the planned changes :)
I am by no stretch of the imagination a networking expert – I most likely missed cases and/or ranges.
To change the RegExp pattern, modify or add the segment(s) inside src/build.js, run it with node, and then paste the result into the src/index.js file.
MIT © Luke Edwards
FAQs
A tiny (171B) utility to check if a hostname is local
We found that local-hostname demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.