normalize-url
10.0.0 · 14 Oct 2026MIT62.8M / weekRepositoryHomepagenpmAtom feed
In short
5 breaking5 new2 fixed
- Breaking
Require Node.js 22 6c95de2
- Breaking
Throw a
TypeErrorwhen thedefaultProtocoloption is not a valid scheme, such as'https://'a8c34ae - Breaking
The query is now always re-serialized, even with
sortQueryParameters: false65f62ef - Breaking
The
removeDirectoryIndexoption now runs aftertransformPath, so the function also receives the index file 65f62ef - Breaking
Many edge cases are now normalized differently (see below). If you store normalized URLs, you may want to normalize them again.
Release note
Breaking
- Breaking
Require Node.js 22 6c95de2
- Breaking
Throw a
TypeErrorwhen thedefaultProtocoloption is not a valid scheme, such as'https://'a8c34ae - Breaking
The query is now always re-serialized, even with
sortQueryParameters: false65f62efPreviously, disabling sorting kept the query exactly as written. Now it is written the way
URLSearchParamswrites it, so%20becomes+and an escape that is not valid UTF-8, like%E9, becomes%EF%BF%BD.
- Breaking
The
removeDirectoryIndexoption now runs aftertransformPath, so the function also receives the index file 65f62ef - Breaking
Many edge cases are now normalized differently (see below). If you store normalized URLs, you may want to normalize them again.
Improvements
The
defaultProtocoloption now accepts any protocol, not justhttpandhttpsb2e4135Strip all whitespace from the ends of a URL, including a non-breaking space and a byte order mark left over from copying 13f62a4
Keep repeated query keys in their original order when sorting 5a3e67a
Normalizing an already normalized URL now always gives the same URL
Document the normalizations that happen regardless of the options bb685bc
Fixes
Fix normalization of the protocol, host, port, path, query, fragment, and data URLs 65f62ef
http:/example.comno longer becomeshttp://http/example.com%252Fin a path no longer becomes%2F, which is a different URLA trailing
/in the query is no longer removednormalizeProtocol: falsenow keeps a protocol-relative URL, even withdefaultProtocol: 'https'A data URL without a comma no longer throws
Fix several data URL cases where the normalized URL was decoded differently by browsers 5d8ff58 cf2aed8 bd39d02
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.