Registry / http-networking / dom-urls

dom-urls

JSON →
library1.1.0jsnpmunverified

dom-urls is a legacy Node.js package that provides a partial implementation of an older W3C URL Spec Draft. It was built on top of URIjs to address limitations in Node.js's native `url` module at the time (specifically, its inability to propagate changes between URL components like host and port). The package is designed for Node.js versions 0.8.0 and above. The current stable version is 1.1.0, released long ago. This package is effectively abandoned, as modern Node.js and browsers now provide a native, robust, and spec-compliant `URL` global object, rendering `dom-urls` obsolete. It lacks active development, modern features, and ESM support.

npm install dom-urls
INSTALL
IMPORT
SIG · DOM-URLS
D
dom-urls
http-networkingjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

URL
const URL = require('dom-urls');
import { URL } from 'dom-urls'; import URL from 'dom-urls';
This package is CommonJS-only and exports the URL constructor as its default export. ESM import syntax will not work and will likely cause a `SyntaxError`.

Demonstrates importing the URL constructor, creating a URL object, accessing its properties, and modifying the host to observe component propagation.

const URL = require('dom-urls'); // Create a new URL object with a relative path and a base URL const url = new URL('relative', 'http://example.com/sub/'); console.log('Original URL:', url.href); // Should be 'http://example.com/sub/relative/' console.log('Protocol:', url.protocol); // 'http:' console.log('Hostname:', url.hostname); // 'example.com' console.log('Pathname:', url.pathname); // '/sub/relative/' // Modify the host and observe changes url.host = 'example.net:8080'; console.log('Modified URL:', url.href); // Should be 'http://example.net:8080/sub/relative/' console.log('New Hostname:', url.hostname); // 'example.net' console.log('New Port:', url.port); // '8080'
Debug
Known issues
breakingThis package is largely obsolete. Modern Node.js environments (v10.0.0+ as of 2018) include a global, spec-compliant `URL` class that fulfills the same purpose, but follows the WHATWG URL standard more rigorously.
fix
Migrate to the native `URL` global object available in Node.js and modern browsers. Example: `const url = new URL('relative', 'http://example.com/sub/');`
affects: All versions
gotchaError handling in `dom-urls` is explicitly stated in its README to be 'very different from the spec'. This can lead to unexpected behavior compared to the official WHATWG URL standard.
fix
Be aware of non-standard error handling. For spec-compliant behavior, use the native `URL` global.
affects: All versions
deprecatedThis package is CommonJS-only and has not been updated in many years, indicating it is no longer maintained. It may have unpatched vulnerabilities or incompatibilities with modern Node.js versions.
fix
Avoid using this package in new projects. For existing projects, prioritize migration to native `URL` objects for security and compatibility.
affects: <=1.1.0
Errors
Common errors & fixes
TypeError: URL is not a constructor
Attempting to use `dom-urls` in an environment where `URL` is already defined globally (e.g., modern Node.js or browser) and you are trying to use the native `URL` without importing `dom-urls` or incorrectly overriding it.
fix
Ensure you are using `const URL = require('dom-urls');` correctly, and consider renaming the imported variable (e.g., `const DomURL = require('dom-urls');`) to avoid conflicts with the native `URL` global. Ideally, migrate to the native `URL` global.
SyntaxError: Unexpected token 'export' (or 'import')
Attempting to use ESM `import` syntax for `dom-urls`, which is a CommonJS module.
fix
Change your import statement to CommonJS: `const URL = require('dom-urls');`
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
urijsrequiredCore parsing and manipulation logic, as indicated by the README.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
dom-urls — npm install dom-urls · libregistry