sindresorhus / normalize-url

Normalize a URL
MIT License
837 stars 123 forks source link

removeSingleSlash should default to false #175

Closed elf-pavlik closed 1 year ago

elf-pavlik commented 1 year ago

https://github.com/sindresorhus/normalize-url#removesingleslash

removeSingleSlash

Type: boolean Default: true

Remove a sole / pathname in the output. This option is independent of removeTrailingSlash.

Looking at https://www.rfc-editor.org/rfc/rfc3986#section-6.2.3

http://example.com
http://example.com/
http://example.com:/
http://example.com:80/

In general, a URI that uses the generic syntax for authority with an empty path should be normalized to a path of "/".

[...]

For example, the second URI above is the normal form for the "HTTP" scheme.

Which is the http://example.com/ version

sindresorhus commented 1 year ago

http://example.com and http://example.com/ are equivalent. I'm not sure of their reasoning for preserving /, but I prefer without the /, as it's cleaner, and this package is often used for presenting URLs, not just comparisons. I don't have any plans to change the defaults.