v2.0.0
Breaking Changes
This release introduces WHATWG URL Standard compliance with breaking API changes for better spec alignment and performance.
Renamed fields
The following field names have been updated to match modern URL standards:
| Old Field | New Field | Notes |
|---|---|---|
relative |
pathname |
Path component of URL |
query |
search |
Now includes ? prefix |
anchor |
hash |
Now includes # prefix |
user |
username |
User credential component |
protocol |
protocol |
Now includes : suffix |
New fields
href- Complete URL stringorigin- Origin component (for HTTP/HTTPS URLs)searchParams- URLSearchParams instance for modern query handling
Performance improvements
The new implementation delivers exceptional performance gains:
- Simple URLs: 3111% faster
- Complex HTTP URLs: 786% faster
- Custom protocols: 1023% faster
- Unicode URLs: 905% faster
Check Benchmark
Migration guide
Update your code to use the new field names:
// Before (v1.x)
const result = parseURI('https://example.com/path?query=value#hash')
console.log(result.relative) // '/path'
console.log(result.query) // 'query=value'
console.log(result.anchor) // 'hash'
console.log(result.protocol) // 'https'
// After (v2.x)
console.log(result.pathname) // '/path'
console.log(result.search) // '?query=value'
console.log(result.hash) // '#hash'
console.log(result.protocol) // 'https:'
console.log(result.searchParams.get('query')) // 'value'