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

Any way to validate broken images? #207

Open
buger opened this issue Dec 20, 2022 · 1 comment
Open

Any way to validate broken images? #207

buger opened this issue Dec 20, 2022 · 1 comment
Labels

Comments

@buger
Copy link

buger commented Dec 20, 2022

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...

@buger buger added the feature label Dec 20, 2022
wjdp added a commit that referenced this issue Jan 28, 2023
@wjdp
Copy link
Owner

wjdp commented Jan 28, 2023

Hey @buger we should be checking for broken images, this bit at the bottom of check_link does that

// Route reference check
switch ref.Scheme() {
case "http":
hT.enforceHTTPS(ref)
hT.checkExternal(ref)
case "https":
hT.checkExternal(ref)
case "file":
hT.checkInternal(ref)
}

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants