1.0.2 • Published 6 months ago

just-domain v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

just-domain

A lightweight utility to quickly extract domains from URLs in both browser and Node.js environments.

Installation

npm install just-domain

Usage

import { justDomain } from 'just-domain';

// Basic usage
console.log(justDomain('https://example.com/path')); // 'example.com'

// Strip www
console.log(justDomain('https://www.example.com', { stripWww: true })); // 'example.com'

// Include port
console.log(justDomain('http://localhost:3000', { includePort: true })); // 'localhost:3000'

// In browser, defaults to current URL if no argument provided
console.log(justDomain()); // current domain

API

justDomain(href?, options?)

Parameters

  • href (optional): URL string to parse. In browser environments, defaults to current page URL.
  • options (optional): Configuration object
    • stripWww: Remove 'www.' prefix if present
    • includePort: Include port number in output if present

License

MIT

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago