{"id":14537,"library":"dom-urls","title":"DOM URLs for Node","description":"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.","status":"abandoned","version":"1.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/passy/node-dom-urls","tags":["javascript","dom","url","urls"],"install":[{"cmd":"npm install dom-urls","lang":"bash","label":"npm"},{"cmd":"yarn add dom-urls","lang":"bash","label":"yarn"},{"cmd":"pnpm add dom-urls","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core parsing and manipulation logic, as indicated by the README.","package":"urijs","optional":false}],"imports":[{"note":"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`.","wrong":"import { URL } from 'dom-urls';\nimport URL from 'dom-urls';","symbol":"URL","correct":"const URL = require('dom-urls');"}],"quickstart":{"code":"const URL = require('dom-urls');\n\n// Create a new URL object with a relative path and a base URL\nconst url = new URL('relative', 'http://example.com/sub/');\n\nconsole.log('Original URL:', url.href); // Should be 'http://example.com/sub/relative/'\nconsole.log('Protocol:', url.protocol); // 'http:'\nconsole.log('Hostname:', url.hostname); // 'example.com'\nconsole.log('Pathname:', url.pathname); // '/sub/relative/'\n\n// Modify the host and observe changes\nurl.host = 'example.net:8080';\n\nconsole.log('Modified URL:', url.href); // Should be 'http://example.net:8080/sub/relative/'\nconsole.log('New Hostname:', url.hostname); // 'example.net'\nconsole.log('New Port:', url.port); // '8080'\n","lang":"javascript","description":"Demonstrates importing the URL constructor, creating a URL object, accessing its properties, and modifying the host to observe component propagation."},"warnings":[{"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/');`","message":"This 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.","severity":"breaking","affected_versions":"All versions"},{"fix":"Be aware of non-standard error handling. For spec-compliant behavior, use the native `URL` global.","message":"Error 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid using this package in new projects. For existing projects, prioritize migration to native `URL` objects for security and compatibility.","message":"This 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.","severity":"deprecated","affected_versions":"<=1.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: URL is not a constructor"},{"fix":"Change your import statement to CommonJS: `const URL = require('dom-urls');`","cause":"Attempting to use ESM `import` syntax for `dom-urls`, which is a CommonJS module.","error":"SyntaxError: Unexpected token 'export' (or 'import')"}],"ecosystem":"npm"}