@ts-utilkit/network
v0.2.0
Published
Network utilities for URL validation, IP address handling, and network-related operations
Maintainers
Readme
@ts-utilkit/network
network Functions - TypeScript utility functions for network operations.
Installation
npm install @ts-utilkit/networkFeatures
- 🚀 TypeScript-first with complete type definitions
- ✅ Comprehensive test coverage (>95%)
- 📦 Tree-shakeable ESM and CommonJS support
- 🔒 Type-safe with strict TypeScript configuration
- 📖 Extensive JSDoc documentation
Available Functions (18)
addQueryParams- Adds query parameters to a URLbuildURL- Constructs a URL from componentsdecodeURLComponent- Decodes a URL componentencodeURLComponent- Encodes a URL componentextractDomain- Extracts the domain from a URLgetDomainParts- Parses domain into subdomain, domain, and TLDgetQueryParams- Extracts query parameters from a URLgetURLPath- Extracts the path from a URLgetURLsFromText- Extracts all URLs from textisLocalhost- Checks if URL is localhostisSameOrigin- Checks if two URLs have the same originisSubdomain- Checks if URL is a subdomain of anotherisValidURL- Validates if a string is a valid URLjoinURLPaths- Joins URL path segmentsnormalizeURL- Normalizes a URL (removes trailing slashes, etc.)parseURL- Parses a URL into its componentsremoveQueryParams- Removes query parameters from a URLsanitizeURL- Sanitizes URL by removing dangerous protocols
Quick Example
import { isValidURL, isValidIP, getURLParams } from '@ts-utilkit/network';
isValidURL('https://example.com'); // true
isValidIP('192.168.1.1'); // true
getURLParams('?page=2&sort=date'); // {page: '2', sort: 'date'}License
MIT © Mykyta Forofontov
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
