v2.0.0
This is a major, breaking change that comes 17 years after v1.2.2. It updates parseUri’s API, adds new features, includes bug/security fixes, adds tests, uses modern JavaScript, becomes a truly universal URI parser, and remains tiny.
Breaking Changes
- Renamed many URI part properties to better mach the built-in
URLobject and other URI libraries:source➜href,userInfo➜userinfo,host➜hostname,relative➜resource,path➜pathname,file➜filename,anchor➜fragment,queryKey➜queryParams. - Updated
queryParamsto be returned as aURLSearchParamsobject, with support for multiple query keys with the same name. - Now uses what used to be called strict parsing mode by default.
- The parsing mode is now specified via an argument (options:
'default','friendly'). - Friendly parsing mode (formerly called loose mode) is now consistent with default mode in considering
'/entry'to include{filename: 'entry'}rather than treating'entry'as part ofdirectory. - Removed
parseUri.optionsproperties, including the ability to rename URI keys or provide a non-standard query parser.
New Features
- Added six new URI parts to result objects:
origin,host,subdomain,domain,tld,suffix.tldincludes extensible support for second-level domains that should be treated as part of the top-level domain (ex:co.uk).
- Added support for IPv6 addresses.
Improvements
- Improved handling for web protocol (
http,https,ws,wss,ftp) and protocol-relative URLs, for parsing accuracy and security. - Improved handling for URNs.
- Added an extensive test suite.
- Added a demo page for testing and comparison with v1, the built-in
URLconstructor, and other libraries.
Bug Fixes
- Fixed an issue where
@in the resource led to incorrect parsing. - Fixed an ReDoS vulnerability with extremely long URIs that use
@in the resource. - Fixed numerous additional edge cases with atypical/invalid URIs.