cargo-docserver
cargo-docserver copied to clipboard
make_index breaks relative links
If make_index detects that the browser left off the final "index.html", for example when requesting "http://MYHOST:4000/MYCRATE", it will append "/index.html" when it looks for the file on disk. The returned response's body will look correct. However, all relative links will be formatted wrong. If the user clicks on one, he'll be directed to a nonexistent URL. For example:
- If I browse to
http://MYHOST:4000/nix, I'll see the familiar doc index for the nix crate - But if I click on a
href="fcntl/index.htmllink, the browser actually interprets it ashttp://MYHOST:4000/fcntl/index.html, which does not exist.
The correct solution, when the user requests a directory URI instead of a file, would be to return a 302 redirect pointing to the index.html file.