Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@diotoborg/et-facere-iusto
Advanced tools
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JDQMB6MRJXQE&source=url)
This package provides a performant way to extract domain names from URLs without using regular expressions or array manipulations.
Learn more about What is a URL
$ npm i --save @diotoborg/et-facere-iusto
# Install bun https://bun.sh/
curl -fsSL https://bun.sh/install | bash
# tests
bun test:watch
{ tld: true }
permit to get Top Level Domain like *.co.uk
ESM import
import extractDomain from '@diotoborg/et-facere-iusto';
Examples
const urls = [
'https://www.npmjs.com/package/@diotoborg/et-facere-iusto',
'http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
'http://user:password@example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
'https://npmjs.com/package/@diotoborg/et-facere-iusto',
'ftp://example.org/resource.txt',
'http://example.co.uk/',
'this.is.my@email.com',
];
extractDomain(urls[0]); // npmjs.com
extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org', 'co.uk', 'email.com' ]
TLD support requires the optional dependency of the psl
library.
Examples
npm i --save-optional psl
const url =
'http://www.example.co.uk:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument';
async function extract(url) {
console.log(await extractDomain(url, { tld: true }));
// example.co.uk
}
// Or
extractDomain(url, { tld: true }).then(console.log);
// example.co.uk
Please note that using the tld flag may significantly slow down the process. Benchmark (old) results:
# extract domain 10,000 times
end ~14 ms (0 s + 13572914 ns)
# extract domain with tld 10,000 times
end ~4.29 s (4 s + 288108681 ns)
$ bun test
$ bun pretty
$ bun benchmark
Contributions are appreciated.
MIT-licensed. See LICENSE.
FAQs
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JDQMB6MRJXQE&source=url)
The npm package @diotoborg/et-facere-iusto receives a total of 0 weekly downloads. As such, @diotoborg/et-facere-iusto popularity was classified as not popular.
We found that @diotoborg/et-facere-iusto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.