-
-
Notifications
You must be signed in to change notification settings - Fork 185
Description
Root-relative links in markdown like [link](/some/dir/file.md) don't get tested as expected, with the default (alternative) config (as opposed to [link](some/dir/file.md). By root-relative I mean those that begin with a / indicating the root of the domain. It appears to ignore those links altogether neither flagging them as good or bad.
I have a page like this:
- [bad link 1 - relative same directory](bad-link-1.md)
- [good link - ../ up to parent and down again](../nested/page.md)
- [bad link 2 - ../ up to parent and down again](../nested/bad-link-2.md)
- [good(ish) link - slash](/bad-links/nested/page.md)
- note: this is a bad link if the site is *hosted* in a sub-directory like this one is
- [bad link 3 - slash](/bad-links/nested/bad-link-3.md)I expect 3 failures on this page, but only get:
✗ [ERR] file:///home/runner/work/some-gh-pages-site/some-gh-pages-site/bad-links/nested/bad-link-1.md | Failed: Cannot find file
✗ [ERR] file:///home/runner/work/some-gh-pages-site/some-gh-pages-site/bad-links/nested/bad-link-2.md | Failed: Cannot find file
✔ [200] file:///home/runner/work/some-gh-pages-site/some-gh-pages-site/bad-links/nested/page.md
As you can see link-3 starts with a /.
reproduction repo
I setup a separate repo to test this. It has 4 bad links.
I'm also testing it in two ways. (1) the suggested alternate config from lychee-action, (2) with the addition of a --base . param.
I've found that setting --base . solves the problem. It finds the rest of the files which the default ignores. I think this should probably be the default / advertised config.
I have 3 test setups in my test repo.
- PR testing via default suggested settings ❌
- PR testing with
--base .added and original args copied ✅ - a post-deploy test of the same code deployed via GitHub pages default deployment agent 🚱 (ignore this)
test 1: PRs as markdown with the default suggested config
Using config:
- name: Link Checker
uses: lycheeverse/[email protected]
with:
fail: true Detects only some bad links
test 2: slightly altered config to specify --base .
All 4 bad links detected including bad-link-3:
✗ [ERR] file:///home/runner/work/some-gh-pages-site/some-gh-pages-site/bad-links/nested/bad-link-3.md | Failed: Cannot find file
Additional commentary
Yes I could adjust every link to not begin with slash and it would have zero ill-effects. However it seems odd that its necessary - especially given that the links are correct when clicking in the markdown on GitHub and also correct as part of the GitHub pages site. There's no guarantee that someone won't include such a link in their branch in the future - and it would silently slip through.
Would a PR adding --base . as part of the default be accepted?