Skip to content

Emit a warning when encountering absolute links #33

Description

@Michael-F-Bryan

It looks like you shouldn't be using absolute links if a document will be viewed from the filesystem (i.e. mdbook build --open) because of the way the browser treats absolute links and the file:// protocol.

We should include a warning which will detect when absolute links are used and hint that they should be converted to relative links (preferably using Diagnostic::with_notes() to also provide a suggested fix).

I'm guessing we'll also need an off-by-default configuration option to skip emitting these warnings.


From rust-lang/chalk#465 (comment):

I had a look into this and don't believe mdbook-linkcheck is missing broken links here, it seems to be how browsers handle the file:// protocol and absolute links.

When you open a document from the filesystem (i.e. mdbook build --open) and click on a link to /clauses.html the browser will dutifully navigate to file:///clauses.html instead of the intended file:///home/michael/Documents/forks/chalk/book/book/clauses.html (or wherever the page happens to be). When served from a web server (i.e. mdbook serve or https://rust-lang.github.io/chalk/book/) this is all handled correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions