URL Toolkit is a lightweight, dependency-free JavaScript library designed to build absolute URLs from a base URL and a relative URL, specifically adhering to RFC 1808. The current stable version is `2.2.5`. The project maintains a steady release cadence, primarily focusing on bug fixes, performance improvements (like regex optimizations), and security updates (such as ReDoS vulnerability patches), with occasional documentation enhancements. Its key differentiator from the native `URL()` constructor in browsers and Node.js is its strict adherence to RFC 1808, which differs from the WHATWG URL Living Standard used by `URL()`. This difference notably affects how 'special URLs' (like `http:///example.com`) are normalized and parsed, making URL Toolkit suitable for environments or applications that require precise RFC 1808 compliance.
npm install url-toolkitVerified import paths — ran on the pinned version, not inferred.
Demonstrates building absolute URLs with and without explicit path normalization, and parsing a URL into its RFC 1808 components.
Thoroughly test URL parsing and resolution if migrating from or using alongside `URL()`. Understand RFC 1808 specifications for expected behavior or use `URL()` if WHATWG standard is preferred.
Upgrade to version `2.2.4` or later to incorporate the patched regular expressions: `npm install url-toolkit@latest`.
Always use `./` prefix for relative URLs with colons if you intend for them to be resolved against the base URL (e.g., `buildAbsoluteURL(baseURL, './a:b')`).
Pass `{ alwaysNormalize: true }` as the third argument to `buildAbsoluteURL` if consistent path normalization is desired: `buildAbsoluteURL(baseURL, relativeURL, { alwaysNormalize: true })`.Upgrade to `url-toolkit@2.1.5` or later to ensure correct handling of semicolons within URL fragments.
For CommonJS, use `const URLToolkit = require('url-toolkit'); URLToolkit.buildAbsoluteURL(...)`. For ESM/TypeScript, use `import { buildAbsoluteURL } from 'url-toolkit';` or `import * as URLToolkit from 'url-toolkit'; URLToolkit.buildAbsoluteURL(...)`.Ensure you are using `import * as URLToolkit from 'url-toolkit';` or `import { buildAbsoluteURL } from 'url-toolkit';` to correctly access the functions.Review the documentation on 'Differences to JS `URL()`' in the `url-toolkit` README. If WHATWG-compliant behavior is required, consider using the native `URL()` constructor instead.
No dependency data recorded yet.