Registry / devops / url-resolve-modern

url-resolve-modern

JSON →
library0.1.0jsnpmunverified

Sequential URL resolution using the standard URL API with resolve-url migration helpers. Version 0.1.0 (first stable release). Zero dependencies. TypeScript types included. Node >=18. Ideal replacement for deprecated resolve-url with same left-to-right resolution model but using native URL API for correctness and performance.

npm install url-resolve-modern
INSTALL
IMPORT
SIG · URL-RESOLVE-MODERN
U
url-resolve-modern
devopsjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

resolveUrl
import { resolveUrl } from 'url-resolve-modern'
import resolveUrl from 'url-resolve-modern'
Named export, not default. ESM-only, no CJS.
resolveUrlFrom
import { resolveUrlFrom } from 'url-resolve-modern'
const { resolveUrlFrom } = require('url-resolve-modern')
Named export. No CommonJS require() support.
isAbsoluteUrl
import { isAbsoluteUrl } from 'url-resolve-modern'
import { isAbsoluteUrl } from 'resolve-url'
Not part of resolve-url. Named export from this package.
UrlResolveError
import { UrlResolveError } from 'url-resolve-modern'
import { UrlResolveError } from 'url-resolve'
Custom error class. Only for this package.

Demonstrates basic resolveUrl, resolveUrlFrom, isAbsoluteUrl, and UrlResolveError usage.

import { resolveUrl, resolveUrlFrom, isAbsoluteUrl, UrlResolveError } from 'url-resolve-modern'; // Basic resolution const result = resolveUrl('https://example.com/a/b/c', 'd'); console.log(result); // 'https://example.com/a/b/d' // With explicit base const result2 = resolveUrlFrom('https://example.com/static/js/app.js', '../css/style.css'); console.log(result2); // 'https://example.com/static/css/style.css' // Check absolute URL console.log(isAbsoluteUrl('https://example.com')); // true console.log(isAbsoluteUrl('relative/path')); // false // Error handling try { resolveUrl('relative/path'); } catch (e) { if (e instanceof UrlResolveError) { console.log('Missing base URL'); } }
Debug
Known issues
breakingPackage is ESM-only and does not support require().
fix
Use import syntax or dynamic import().
affects: >=0.0.0
breakingFirst argument to resolveUrl must be absolute if not in browser context.
fix
Provide an absolute URL as first argument or use resolveUrlFrom.
affects: >=0.0.0
gotcharesolveUrl does not use window.location in Node; throws UrlResolveError if no base.
fix
Use resolveUrlFrom with an explicit base in Node.
affects: >=0.0.0
gotchaPackage is not affiliated with resolve-url; API may differ in edge cases.
fix
Review the migration guide for differences.
affects: >=0.0.0
deprecatedresolve-url is deprecated; this package is an alternative, not a drop-in replacement.
fix
Check compatibility notes for behavior changes.
affects: >=0.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Package is ESM-only; using require() throws error.
fix
Switch to import statement or use dynamic import().
UrlResolveError: Cannot resolve relative URL without a base.
First argument to resolveUrl is relative and not in browser context.
fix
Provide an absolute URL as first argument or use resolveUrlFrom with a base.
TypeError: URL constructor: https://example.com/a is not a valid URL.
Passed an invalid string that cannot be parsed as URL.
fix
Ensure all URL strings are valid (e.g., encode spaces).
Module not found: Can't resolve 'url-resolve-modern' in ...
Package not installed or typo in import path.
fix
Run npm install url-resolve-modern and verify import path.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
url-resolve-modern — npm install url-resolve-modern · libregistry