Skip to content

Commit

Permalink
Remove blacklisting for URIs starting with /-/ and move /menus/ r…
Browse files Browse the repository at this point in the history
…outes to `/-/menus/`
  • Loading branch information
GuillaumeGomez committed Aug 9, 2023
1 parent 75541b6 commit fc21f64
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ mod tests {

let response = env
.frontend()
.get("/menus/platforms/dummy/0.4.0/x86_64-pc-windows-msvc")
.get("/-/menus/platforms/dummy/0.4.0/x86_64-pc-windows-msvc")
.send()?;
assert!(response.status().is_success());

Expand Down
10 changes: 5 additions & 5 deletions src/web/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use axum_extra::routing::RouterExt;
use std::convert::Infallible;
use tracing::{debug, instrument};

const INTERNAL_PREFIXES: &[&str] = &["-", "about", "crate", "releases", "sitemap.xml"];
const INTERNAL_PREFIXES: &[&str] = &["about", "crate", "releases", "sitemap.xml"];

#[instrument(skip_all)]
pub(crate) fn get_static<H, T, S, B>(handler: H) -> MethodRouter<S, B, Infallible>
Expand Down Expand Up @@ -237,19 +237,19 @@ pub(super) fn build_axum_routes() -> AxumRouter {
get_internal(super::source::source_browser_handler),
)
.route(
"/menus/platforms/:name/:version/:target",
"/-/menus/platforms/:name/:version/:target",
get_internal(super::crate_details::get_all_platforms),
)
.route(
"/menus/platforms/:name/:version/:target/",
"/-/menus/platforms/:name/:version/:target/",
get_internal(super::crate_details::get_all_platforms),
)
.route(
"/menus/platforms/:name/:version/:target/*path",
"/-/menus/platforms/:name/:version/:target/*path",
get_internal(super::crate_details::get_all_platforms),
)
.route(
"/menus/releases/:name",
"/-/menus/releases/:name",
get_internal(super::crate_details::get_all_releases),
)
.route(
Expand Down
2 changes: 1 addition & 1 deletion src/web/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ mod test {
// test rustdoc pages stay on the documentation
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/menus/releases/hexponent")
.get("/-/menus/releases/hexponent")
.send()?
.text()?,
);
Expand Down
2 changes: 1 addition & 1 deletion static/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function loadAjaxMenu(menu, id, msg, path, extra) {
document.getElementById(id).innerHTML = `Failed to load ${msg}`;
}
};
xhttp.open("GET", `/menus/${path}/${crateName}${extra}`, true);
xhttp.open("GET", `/-/menus/${path}/${crateName}${extra}`, true);
xhttp.send();
};

Expand Down

0 comments on commit fc21f64

Please sign in to comment.