Skip to content

rustdoc: search URLs should be based off the documentation root #84319

Open
@jsha

Description

@jsha

When you do a search on a rustdoc page, we use the history API to modify the URL bar and represent the current search. For instance if you search for "vec" from the String page, you'd get:

https://doc.rust-lang.org/std/string/struct.String.html?search=vec

But if you searched for "vec" from the slice page, you'd get:

https://doc.rust-lang.org/std/slice/index.html?search=vec

Conceptually, though, these are the same: the search results for "vec" within /std/. Since History.pushState() lets us choose whatever URL we want within the same origin, we should remove the part that's specific to the page you started on, and generate a URL like so:

https://doc.rust-lang.org/std/index.html?search=vec

(note the index.html rather than just /std/, so this works properly when loading local files).

I'm happy to work on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsArea: Rustdoc's JS front-endT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions