Skip to content

Commit e0a5fef

Browse files
jshasyphar
authored andcommitted
Omit target-redirect from permalink
1 parent 6391e47 commit e0a5fef

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/web/rustdoc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
476476
};
477477

478478
let permalink_path = format!(
479-
"/crate/{}/{}{}{}",
480-
name, latest_version, target_redirect, query_string
479+
"/{}/{}/{}{}",
480+
name, latest_version, inner_path, query_string
481481
);
482482

483483
let latest_path = format!("/crate/{}/latest{}{}", name, target_redirect, query_string);
@@ -834,7 +834,7 @@ mod test {
834834
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
835835
assert!(body.contains("<a href=\"/crate/dummy/latest/source/\""));
836836
assert!(body.contains("<a href=\"/crate/dummy/latest\""));
837-
assert!(body.contains("<a href=\"/crate/dummy/0.1.0/target-redirect/x86_64-unknown-linux-gnu/dummy/index.html\""));
837+
assert!(body.contains("<a href=\"/dummy/0.1.0/dummy/index.html\""));
838838
Ok(())
839839
})
840840
}

static/menu.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,7 @@
241241
if (document.location.hash != "") {
242242
permalink.href += "#" + document.location.hash;
243243
}
244-
// Note: It would be nicer to do history.replaceState here and avoid a page load
245-
// (that's what GitHub does), but the permalink goes through a redirect, so you wind up
246-
// with a weird URL like:
247-
// http://localhost:3000/crate/regex/1.3.1/target-redirect/x86_64-unknown-linux-gnu/regex/index.html
248-
permalink.click();
244+
history.replaceState({}, null, permalink.href);
249245
}
250246
});
251247
})();

0 commit comments

Comments
 (0)