Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relative broken links not detected #183

Closed
lenisha opened this issue Mar 16, 2021 · 6 comments · Fixed by #217
Closed

relative broken links not detected #183

lenisha opened this issue Mar 16, 2021 · 6 comments · Fixed by #217
Assignees
Labels
bug Something isn't working
Milestone

Comments

@lenisha
Copy link

lenisha commented Mar 16, 2021

Relative Links in the github pages index.html are broken but not detected:

https://github.com/lenisha/linkchecker-test/runs/2122896789?check_suite_focus=true

+ lychee '--exclude=^(javascript|chrome):.*' --verbose --accept=200,403,429 --base-url https://lenisha.github.io/linkchecker-test/   https://lenisha.github.io/linkchecker-test/ --output /tmp/lychee/out.md
+ exit_code=0
+ '[' 0 -ne 0 ']'
+ cat /tmp/lychee/out.md
+ echo
+ echo ::set-output name=exit_code::0
📝 Summary
---------------------
🔍 Total...........17
✅ Successful......17
⏳ Timeouts.........0
🔀 Redirected.......0
👻 Excluded.........0
🚫 Errors...........0

while index.thml has broken link https://github.com/lenisha/linkchecker-test/blob/main/index.html#L53

<a class="nav-link pr-3" href="./abouterror.html">About</a>

that points to https://lenisha.github.io/linkchecker-test/abouterror.html

Could it be also checked locally? Similar to discussion #15

@lenisha lenisha changed the title broken links not detected relative broken links not detected Mar 16, 2021
@lenisha
Copy link
Author

lenisha commented Mar 16, 2021

@mre is there any option to detect problems with relative links right now?
I tried to go against the live website with base-url

lychee '--exclude=^(javascript|chrome):.*' --verbose --base-url https://lenisha.github.io/linkchecker-test/   https://lenisha.github.io/linkchecker-test/ 

and tried against files files in PR

lychee  --exclude="^(javascript|chrome):.*"   --accept=200,403,429 "**/*.md" "**/*.html"

non have found the simple error

<a class="nav-link pr-3" href="./abouterror.html">About</a>

@pawroman
Copy link
Member

@mre is there any option to detect problems with relative links right now?

There should be, once #99 is merged. Right now, link-parsing debugging is a bit cumbersome (e.g. you have to modify the source).

@mre
Copy link
Member

mre commented Mar 17, 2021

No clue why it doesn't find the relative links, though. @pawroman do you know why?

@lenisha
Copy link
Author

lenisha commented Mar 17, 2021

@mre @pawroman weird thing is when I explicitly point to index.html page it finds it

lychee --verbose '--exclude=^(javascript|chrome):.*' --accept=200,403,429 --base-url https://lenisha.github.io/linkchecker-test/ https://lenisha.github.io/linkchecker-test/index.html --output /tmp/lychee/out.md
+ exit_code=2
+ '[' 2 -ne 0 ']'
++ dirname lychee/out.md
+ mkdir -p lychee
+ echo 'Errors were reported while checking the availability of links.'
+ echo
+ echo '```'
+ echo
+ cat /tmp/lychee/out.md
+ echo
📝 Summary
+ echo '```'
+ echo
+ echo '[Full Github Actions output](https://github.com/lenisha/linkchecker-test/actions/runs/662263907?check_suite_focus=true)'
+ cat /tmp/lychee/out.md
+ echo
+ echo ::set-output name=exit_code::2
---------------------
🔍 Total...........28
✅ Successful......27
⏳ Timeouts.........0
🔀 Redirected.......0
👻 Excluded.........0
🚫 Errors...........1

Errors in https://lenisha.github.io/linkchecker-test/index.html
✗ https://lenisha.github.io/linkchecker-test/abouterror.html [404 Not Found]

also wonder why --verbose does not work in this combination

and local files could not detect it even with explicit file pointer:

+ lychee '--exclude=^(javascript|chrome):.*' --accept=200,403,429 index.html 
+ exit_code=0
📝 Summary
+ '[' 0 -ne 0 ']'
+ cat /tmp/lychee/out.md
+ echo
+ echo ::set-output name=exit_code::0
---------------------
🔍 Total...........17
✅ Successful......17
⏳ Timeouts.........0
🔀 Redirected.......0
👻 Excluded.........0
🚫 Errors...........0

@mre
Copy link
Member

mre commented Mar 23, 2021

After thinking about this some more I think I know what's up:
The html file extension triggers the HTML mode in lychee. URLs without any file extensions get treated as plaintext, in which case relative URLs don't exist (currently at least).
We can probably safely assume that a URL returns HTML by default, so we have to change the condition here to return FileType::HTML by default if there is no extension:

file_type: FileType::from(url.as_str()),

@mre
Copy link
Member

mre commented Apr 12, 2021

@lenisha, this is fixed in master now. Will publish a new version of the lychee-action (1.0.7) shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants