Files
rust/tests/rustdoc-html
Jacob Pratt 10edd16dcb Rollup merge of #152977 - arferreira:fix-extern-html-relative-depth, r=notriddle
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
2026-02-24 22:51:40 -05:00
..
2026-02-24 11:41:26 -05:00
2026-02-10 18:00:54 +00:00