Skip to content

Go to latest version breaks for /src/ when item was renamed #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jyn514 opened this issue Dec 7, 2019 · 6 comments · Fixed by #1363
Closed

Go to latest version breaks for /src/ when item was renamed #513

jyn514 opened this issue Dec 7, 2019 · 6 comments · Fixed by #1363
Labels
E-easy Effort: Should be easy to implement and would make a good first PR mentor This has instructions for getting started

Comments

@jyn514
Copy link
Member

jyn514 commented Dec 7, 2019

I noticed this while investigating #357: any time you click 'Go To Latest' while viewing source code, it redirects to https://docs.rs/:crate/:version/src/:crate/?search=rs. This is clearly not desired behavior (it gives a 404).

Don't have time to debug right now but the relevant code is

fn path_for_version(req_path: &[&str], target_name: &str, conn: &Connection) -> String {
.

@jyn514
Copy link
Member Author

jyn514 commented Dec 27, 2019

I can't reproduce this bug 😆

@jyn514 jyn514 changed the title Go to latest version should work when viewing source Go to latest version breaks for /src/ when item was renamed Dec 27, 2019
@jyn514
Copy link
Member Author

jyn514 commented Dec 27, 2019

Ok it turns out the bug is much more limited than I thought which is good - it's only if the item was renamed or deleted. Test case: https://docs.rs/pyo3/0.2.7/src/pyo3/objects/exc.rs.html. This redirects to https://docs.rs/pyo3/0.8.4/src/pyo3/?search=rs, which gives a 404. I think the right thing to do would be to redirect to https://docs.rs/pyo3/0.8.4/pyo3/?search=exc - that doesn't keep you in source view, but you still get a search page.

@jyn514
Copy link
Member Author

jyn514 commented Dec 27, 2019

Mentoring instructions:

This only requires changing the frontend.

  1. Check here if the 3rd part of the URL is src; if so, don't add it to crate_root.
  2. Currently, we unconditionally search for the 2nd part of the filename, which for source files is the file extension (usually .rs). Change this to search for the 1st part of the filename if the 3rd part of the URL is src.

There's more information about this in the comments for the function I linked.

Note that the URL may include both a platform and src, e.g. https://docs.rs/pyo3/0.2.7/x86_64-pc-windows-msvc/src/pyo3/lib.rs.html.

@jyn514 jyn514 added E-easy Effort: Should be easy to implement and would make a good first PR mentor This has instructions for getting started labels Dec 27, 2019
@Zexbe
Copy link
Contributor

Zexbe commented Feb 19, 2020

I found another example, If you go to this link
https://docs.rs/playground/0.1.0/playground/
The go to latest version has a bad link that goes to
https://docs.rs/playground/0.1.1/playground/?search=playground

@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2020

This is #502, I have an open PR waiting for me to add unit tests review: #509

@jyn514
Copy link
Member Author

jyn514 commented Apr 17, 2021

This has been half-fixed - we now redirect to https://docs.rs/pyo3/0.13.2/pyo3/?search=rs, which is correct except that the search query is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Effort: Should be easy to implement and would make a good first PR mentor This has instructions for getting started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants