wjdp / htmltest

:white_check_mark: Test generated HTML for problems
MIT License
323 stars 54 forks source link

Any way to validate broken images? #207

Open buger opened 1 year ago

buger commented 1 year ago

Is your feature request related to a problem? Please describe. I have found a bunch of images which had wrong "src", but htmltest missed this issues. I quickly checked the code, and seems like it validate only existence of attributes like src or rel, but does not actually check if image exists, like it does with links.

Describe the solution you'd like Validate that image src are actually exists

Describe alternatives you've considered Interestingly that I tried to find alternative solution, using my static side builder, in my case Hugo. For links it does provide special helper calledref, which errors if url is wrong, but for images there is no such thing...

wjdp commented 1 year ago

Hey @buger we should be checking for broken images, this bit at the bottom of check_link does that https://github.com/wjdp/htmltest/blob/078245d94f4acf862d0bf8a1b053bc875500e1f6/htmltest/check-img.go#L115-L124 https://github.com/wjdp/htmltest-github-actions/blob/078245d94f4acf862d0bf8a1b053bc875500e1f6/htmltest/check-img.go#L115-L124

I just added an additional test to ensure we fail on 404s for images as we didn't have that and it's behaving as expected.

Do you have a URL that's passing for you but should be failing?