DOM URLs for Node

1.1.0 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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'

view raw JSON →