Skip to content
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

refs #1979, #1992: workaround for settings.js not served from the root #1993

Merged
merged 1 commit into from
Jan 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/web/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ pub(crate) async fn rustdoc_redirector_handler(
// This is fixed in rustdoc, but pending a rebuild for
// docs that were affected by this bug.
// https://github.com/rust-lang/docs.rs/issues/1979
if target.starts_with("search-") {
if target.starts_with("search-") || target.starts_with("settings-") {
return try_serve_legacy_toolchain_asset(storage, config, target).await;
} else {
return Err(err.into());
Expand Down Expand Up @@ -2595,8 +2595,9 @@ mod test {
});
}

#[test]
fn fallback_to_root_storage_for_search_js_assets() {
#[test_case("search-1234.js")]
#[test_case("settings-1234.js")]
fn fallback_to_root_storage_for_some_js_assets(path: &str) {
// test workaround for https://github.com/rust-lang/docs.rs/issues/1979
wrapper(|env| {
env.fake_release()
Expand All @@ -2606,8 +2607,7 @@ mod test {
.create()?;

env.storage().store_one("asset.js", *b"content")?;
env.storage()
.store_one("search-1234.js", *b"more_content")?;
env.storage().store_one(path, *b"more_content")?;

let web = env.frontend();

Expand All @@ -2617,8 +2617,8 @@ mod test {
);
assert!(web.get("/asset.js").send()?.status().is_success());

assert!(web.get("/search-1234.js").send()?.status().is_success());
let response = web.get("/dummy/0.1.0/search-1234.js").send()?;
assert!(web.get(&format!("/{path}")).send()?.status().is_success());
let response = web.get(&format!("/dummy/0.1.0/{path}")).send()?;
assert!(response.status().is_success());
assert_eq!(response.text()?, "more_content");

Expand Down