NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.09k stars 14.07k forks source link

Should `meta.homepage` endswith a trailling `/`? #330032

Open Sigmanificient opened 3 months ago

Sigmanificient commented 3 months ago

Issue description

Seems like a third of packages have meta.homepage that endswith a trailing /.

Steps to reproduce

$ grep -rP 'homepage = ".*/"' . | wc -l
7882
$ grep -rP 'homepage = ".*[^/]"' . | wc -l
23181

In the doc, the given example also endswith a trailing /: https://nixos.org/manual/nixpkgs/stable/#var-meta-homepage

Newest CONTRIBUTING.md, also use the trailing / in editorconfig url:

https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md?plain=1#

Normalizing them either way would be nice

xzfc commented 3 months ago

It's a matter of the style only for root paths (e.g. example.com and example.com/ are equivalent).


For non-root paths they might point to different pages. Examples found in the Nixpkgs repo:

If both are available, I'd suggest to use a canonical one or the one that responds with 200 OK rather than 301 Moved Permanently.

emilazy commented 3 months ago

FWIW, I consider https://example.com/ canonical for root paths, and my understanding is that the WHATWG URL Standard concurs (new URL("https://example.com").href === "https://example.com/", .origin === "https://example.com", .pathname === "/", the results are the same for "https://example.com/"). Plus it just makes sense, since it results in GET /.

But yes, other than that they’re absolutely not equivalent, so it doesn’t make sense to have a general rule. We could do a tree‐wide sweep to resolve 301 redirects or pick one arbitrarily when both are valid and return the exact same content, but I’m unconvinced it’s worth it.

YoshiRulz commented 3 months ago

'Canonical' refers to <link rel="canonical"/> (or a 301's target), i.e. a choice made by webmasters, rather than anything that's canonical to a spec.