Skip to content

root-dir incorrectly applies to links in remote HTML files #1964

@katrinafyi

Description

@katrinafyi

i have made a test .md file at: https://gist.githubusercontent.com/katrinafyi/daefc003e04b7c2f73cb54615510dce0/raw/fe1b03f7a328e169b7d6445ecbac34053b526e8f/lychee-url-mapping-test-file.md

this has a number of links, one of which is [root](/root). if we point lychee at this URL with the root-dir option, it looks does this:

$ lychee --dump --root-dir /tmp https://gist.githubusercontent.com/katrinafyi/daefc003e04b7c2f73cb54615510dce0/raw/fe1b03f7a328e169b7d6445ecbac34053b526e8f/lychee-url-mapping-test-file.md 
[...]
https://gist.githubusercontent.com/tmp/root

this is merging the root-dir into the implicit base url from the file's URL location. this is the same as it does with --root-dir + --base-url and it is always wrong.

two possible fixes to make this make sense:

  • only apply root-dir to local files
  • /root link in remote files should become /tmp/root

i strongly suggest the first way. in fact, i wrote the --root-dir help assuming it already worked like that:

lychee --root-dir <ROOT_DIR>: Root directory to use when checking absolute links in local files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions