github sindresorhus/normalize-url v10.0.0

4 hours ago

Breaking

  • Require Node.js 22 6c95de2
  • Throw a TypeError when the defaultProtocol option is not a valid scheme, such as 'https://' a8c34ae
  • 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.
  • The removeDirectoryIndex option now runs after transformPath, so the function also receives the index file 65f62ef
  • 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

Don't miss a new normalize-url release

NewReleases is sending notifications on new releases.