Registry / http-networking / component-url

component-url

JSON →
library0.2.1jsnpmunverified

A lightweight URL parser using the browser's `<a>` tag for resolution. Version 0.2.1 is the latest stable release; the package appears unmaintained since 2013. Provides parse, isAbsolute, isRelative, isCrossDomain functions. Uses native DOM parsing (no regex) but only works in browsers, not Node.js. Very minimal API compared to modern URL parsers like URL constructor or whatwg-url.

npm install component-url
INSTALL
IMPORT
SIG · COMPONENT-URL
C
component-url
http-networkingjavascriptv0.2.1
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 module (require)
var url = require('url');
import url from 'url';
CommonJS only; no ESM support. Package is not published on npm; use Component build tool.
url.parse
url.parse('http://example.com')
new URL('http://example.com')
Different API from Node.js url.parse; returns object with 'query' as string, not parsed.
url.isAbsolute
url.isAbsolute('http://a.com')
url.isAbsolute('/relative')
Returns true if URL has a scheme; false for protocol-relative '//a.com'? Check source for behavior.

Parses a URL and demonstrates all properties plus utility checks.

var url = require('url'); var parsed = url.parse('http://example.com:3000/store/shoes?sort=desc'); console.log(parsed.protocol); // 'http:' console.log(parsed.host); // 'example.com:3000' console.log(parsed.port); // 3000 console.log(parsed.hostname); // 'example.com' console.log(parsed.pathname); // '/store/shoes' console.log(parsed.search); // '?sort=desc' console.log(parsed.query); // 'sort=desc' console.log(parsed.hash); // '' console.log(parsed.href); // 'http://example.com:3000/store/shoes?sort=desc' console.log(url.isAbsolute('http://a.com')); // true console.log(url.isRelative('/foo')); // true console.log(url.isCrossDomain('http://other.com')); // true (if page is on different domain)
Debug
Known issues
breakingOnly works in browser (uses <a> tag). Not compatible with Node.js.
fix
Use Node's built-in url module or whatwg-url for server-side.
affects: >=0.0.0
gotchaRelative URLs resolve against current page's base URL, leading to unexpected results.
fix
Always pass absolute URLs if you need consistent parsing.
affects: >=0.0.0
deprecatedPackage is abandoned (last release 2013). No bug fixes or security updates.
fix
Use built-in URL constructor (https://developer.mozilla.org/en-US/docs/Web/API/URL) or whatwg-url.
affects: >=0.0.0
gotchaReturns query as string, not parsed object. No automatic query string parsing.
fix
Use URLSearchParams or a query parser manually.
affects: >=0.0.0
Errors
Common errors & fixes
ReferenceError: window is not defined
Running in Node.js where there is no DOM <a> element.
fix
Use Node's built-in url module: const url = require('url'); url.parse('http://...');
Cannot find module 'url'
Not installed via npm; this package is for Component build system only.
fix
Install with 'component install component/url' or use a browser-ready bundler like Duo.
Uncaught TypeError: url.parse is not a function
Using the Node.js url module's parse incorrectly or importing wrong package.
fix
Ensure you are using this specific package (component/url) via Component or copy source.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
component-url — npm install component-url · libregistry