docs.rs icon indicating copy to clipboard operation
docs.rs copied to clipboard

Redirect to /crate/:crate/:version in more places instead of 404ing

Open jyn514 opened this issue 5 years ago • 3 comments

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.

jyn514 avatar Feb 11 '20 03:02 jyn514

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)

repnop avatar Mar 31 '20 22:03 repnop

That's a separate issue from this one, but it would be great to have!

jyn514 avatar Mar 31 '20 22:03 jyn514

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.

syphar avatar Aug 03 '23 17:08 syphar