docs.rs
docs.rs copied to clipboard
Redirect to /crate/:crate/:version in more places instead of 404ing
Currently, the following places redirect to https://docs.rs/crate/bat/0.12.1:
- https://docs.rs/crate/bat/
- https://docs.rs/crate/bat/0.12.1/
- https://docs.rs/bat
- https://docs.rs/bat/
- https://docs.rs/bat/0.12.1
- https://docs.rs/bat/0.12.1/
- https://docs.rs/bat/0.12.1/bat
- https://docs.rs/bat/0.12.1/i686-unknown-linux-gnu
- https://docs.rs/bat/0.12.1/bat/
- https://docs.rs/bat/0.12.1/i686-unknown-linux-gnu/
- https://docs.rs/bat/0.12.1/i686-unknown-linux-gnu/bat
- https://docs.rs/bat/0.12.1/i686-unknown-linux-gnu/bat/
The following places give a 404:
- https://docs.rs/crate/bat/0.12.1//
We should be more consistent and redirect the above as well.
I use the DuckDuckGo bangs feature a lot to search for crates on docs.rs using the !drs cratename bang, however it doesn't seem to work with crates that have hyphens in the name like async-std, for example. I get redirected to https://docs.rs/async%2Dstd -- which upon pasting that looks like its because it percent encodes the hyphen! I wouldn't mind putting in a PR to percent decode the parameters if that's a change everyone is okay with :+1: (edit: well, assuming that's the problem haha)
That's a separate issue from this one, but it would be great to have!
I just rechecked the URLs above, the only piece missing is the double slash in the end.
This could be implemented at the axum router level, or easier just a simple axum middleware.