Skip to content

Fix "go to latest version" for /src/ when an item was renamed #1363

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

Merged
merged 1 commit into from
Jun 14, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 17, 2021

Fixes #513.

@jyn514 jyn514 added the A-backend Area: Webserver backend label Apr 17, 2021
Comment on lines +254 to +263
let mut updated = ["src", &package.name, src].join("/");
updated += ".html";
let source_html = format!(
"<html><head></head><body>{}</body></html>",
std::str::from_utf8(data).expect("invalid utf8")
);
rustdoc_files.push((
Box::leak(Box::new(updated)),
Box::leak(source_html.into_bytes().into_boxed_slice()),
));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me so long to debug - the HTML rewriter doesn't actually do anything unless at least these tags exist.

Comment on lines 275 to 277
if path.starts_with("/") {
failure::bail!("absolute paths not supported");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also took ages to debug.

@jyn514 jyn514 force-pushed the src-redirect branch 3 times, most recently from ca2ce2f to cc080d3 Compare April 17, 2021 22:34
@jyn514
Copy link
Member Author

jyn514 commented Jun 12, 2021

@syphar do you have time to review this?

@jyn514 jyn514 added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Jun 12, 2021
@syphar
Copy link
Member

syphar commented Jun 12, 2021

@jyn514 I will check it out, probably this weekend.

Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I went through it, as far as I know the code.

In general I remember that especially all this redirecting was touched to often that it's actually covered with tests quite well. (please correct me if I'm wrong).

Apart from my wish for an explaining comment, there is only one thing that I found in manual testing:

When the old version's URL had a line-number attached (with #100 for example), it would also end up in the search-URL. Since it does not end up in the search-field, we could just leave it.

@jyn514
Copy link
Member Author

jyn514 commented Jun 13, 2021

In general I remember that especially all this redirecting was touched to often that it's actually covered with tests quite well. (please correct me if I'm wrong).

Yes, redirects are tested quite well (I think they may have been the first thing we added tests for).

When the old version's URL had a line-number attached (with #100 for example), it would also end up in the search-URL. Since it does not end up in the search-field, we could just leave it.

Hmm, I don't mind keeping it (working on that now), but it shouldn't make a difference one way or another like you said.

@jyn514 jyn514 added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Jun 13, 2021
@jyn514
Copy link
Member Author

jyn514 commented Jun 14, 2021

When the old version's URL had a line-number attached (with #100 for example), it would also end up in the search-URL.

I just realized this is a pre-existing bug - I'd like to leave it for a follow up. Feel free to open an issue for it :)

@jyn514 jyn514 merged commit 4924b95 into rust-lang:master Jun 14, 2021
@jyn514 jyn514 deleted the src-redirect branch June 14, 2021 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend Area: Webserver backend S-waiting-on-author Status: This PR is incomplete or needs to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go to latest version breaks for /src/ when item was renamed
2 participants