UmbrellaDocs / linkspector

Uncover broken links in your content.
Apache License 2.0
59 stars 8 forks source link

Markdown links with relative path always failing #22

Closed atteggiani closed 3 months ago

atteggiani commented 6 months ago

Hello, I am trying to update my CI/CD from using Markdown link check action to Linkspector.

I set my baseURL in the configuration file, but only the absolute links get correctly evaluated, while all the markdown links that use relative paths fail.

For example, if my root directory is structured like this:

-- docs
    |-- dir1
    |    |-- file1.md
    |
    |-- dir2
         |-- file2.md

in the the file1.md a link formatted as:

However, they both are valid links.

Am I missing something? Is there a way to make links with a relative path not being falsely detected as failing?

Thank you!

gaurav-nelson commented 6 months ago

Thank you for testing and creating the issue @atteggiani Looks like a bug. I'll do a fix.

gaurav-nelson commented 5 months ago

UPdATE: On inspecting this further, I found that the issue needs some updates to the logic on how linkspector is processing links. The issue is that path.join(dirname, link.url) is not correctly resolving relative paths. dirname is the directory where linkspector is running, not the directory of the file that contains the link.

To resolve this issue, I'll need to separate hyperlinks checks and file links check. This will need some work.

matifali commented 1 month ago

is baseURL a required parameter? What if we are adding new docs that are not yet published?

gaurav-nelson commented 1 month ago

@matifali

is baseURL a required parameter?

No, it is not a required parameter. I'll update the README to reflect this.

What if we are adding new docs that are not yet published?

If you are specifying links to the new doc set in your docs with [sample](/new-link.md) you can specify baseURL with the dir path, for example: baseUrl: ./new-folder/new-docs. Try that and create an issue if that doesn't work.