Skip to content

Base URL breaks all local links in local files, except for root-relative #2000

@katrinafyi

Description

@katrinafyi

Bizarrely, using a base-url causes lychee to fail to resolve local links except for root-relative links.

We will make a test file which has 3 local links, all of which should be valid.

touch a.html b.html
echo "[a](a.html)
[b](/b.html)
[b](file://$(pwd)/test.md)
[b](https://github.com)
" > test.md
cargo  run -- --verbose --base-url $(pwd) test.md

The output is doubly surprising because the file:// URLs which are errors actually exist on disk, and the one which does not exist on disk is counted as valid.

   [ERROR] file:///home/rina/progs/lychee/a.html | Cannot find file: File not found. Check if file exists and path is correct
     [200] file:///b.html
     [200] https://github.com/
   [ERROR] file:///home/rina/progs/lychee/test.md | Cannot find file: File not found. Check if file exists and path is correct

I think that there's some double-handling of base-url in file checker, which is re-inserting base URL to the beginning of all file:// URLs. This makes the file:///b.html valid and it makes the other ones into broken links like

file:///home/rina/progs/lychee/home/rina/progs/lychee/test.md

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