Packages

normalize-url

10.0.0 · 14 Oct 2026MIT62.8M / weekRepositoryHomepagenpmAtom feed

Your version

10.0.0

Latestmajor14 Oct 2026Where it was published

In short

5 breaking5 new2 fixed

  • Breaking

    Require Node.js 22 6c95de2

  • Breaking

    Throw a TypeError when the defaultProtocol option is not a valid scheme, such as 'https://' a8c34ae

  • Breaking

    The query is now always re-serialized, even with sortQueryParameters: false 65f62ef

  • Breaking

    The removeDirectoryIndex option now runs after transformPath, 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 TypeError when the defaultProtocol option is not a valid scheme, such as 'https://' a8c34ae

  • Breaking

    The query is now always re-serialized, even with sortQueryParameters: false 65f62ef

    • Previously, disabling sorting kept the query exactly as written. Now it is written the way URLSearchParams writes it, so %20 becomes + and an escape that is not valid UTF-8, like %E9, becomes %EF%BF%BD.

  • Breaking

    The removeDirectoryIndex option now runs after transformPath, 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 defaultProtocol option now accepts any protocol, not just http and https b2e4135

  • Strip 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.com no longer becomes http://http/example.com

    • %252F in a path no longer becomes %2F, which is a different URL

    • A trailing / in the query is no longer removed

    • normalizeProtocol: false now keeps a protocol-relative URL, even with defaultProtocol: '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


v9.0.1...v10.0.0

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.