mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-29 20:20:59 +03:00
10edd16dcb
Fix relative path handling for --extern-html-root-url When `--extern-html-root-url` receives a relative path (like `../`), rustdoc uses it as a literal prefix regardless of page depth. This works at depth 1 (`crate/index.html`) but breaks at depth 2+ (`crate/module/struct.Foo.html`) because the relative path doesn't account for the extra nesting. This patch detects relative vs absolute URLs in the `Remote` branch of `url_parts` and prepends the necessary `../` segments based on the current page depth. Absolute URLs (`https://...`) and server-absolute paths (`/docs/...`) are unchanged. This makes relative paths a viable option for `--extern-html-root-url`, which they weren't before. Related to rust-lang/rust#152917, which exposed that relative paths weren't handled correctly. cc @eggyal