lychee/fixtures
MichaIng 92a9bca23f
feat: skip fragment checking for unsupported MIME types (#1744)
* feat: skip fragment checking for unsupported MIME types

The remote URL/website checker currently passes all URLs with fragments to the fragment checker as HTML document, even if it is a different or unsupported MIME type. This can cause false fragment checking for Markdown documents, failures for other MIME types, especially binaries, and unnecessary traffic for large downloads, which are always finished completely, if the fragment checker is invoked.

This commit checks the Content-Type header of the response:
- Only if it is `text/html`, it is passed to the fragment checker as HTML type.
- Only if it is `text/markdown`, of `text/plain` and URL path ends on `.md`, it is passed to the fragment checker as Markdown type.
- In all other cases, the fragment checker is skipped and the HTTP status is returned.

To invoke the fragment checker with a variable document type, a new `FileType` argument is added to the `check_html_fragment()` function.

The fragment checker test and fixture are adjusted to match the expected result: checking a binary file via remote URL with fragment is now expected to succeed, since its Content-Type header does not invoke the fragment checker anymore.

Signed-off-by: MichaIng <micha@dietpi.com>

* Update fixtures/fragments/file1.md

Co-authored-by: MichaIng <micha@dietpi.com>

---------

Signed-off-by: MichaIng <micha@dietpi.com>
Co-authored-by: Matthias Endler <matthias@endler.dev>
2025-07-06 10:46:06 +02:00
..
bench Fix spelling and remove unneeded trailing whitespace (#1417) 2024-04-26 08:22:44 +02:00
cache Fix deserialize of lycheecache status codes (#685) 2022-07-15 22:45:24 +02:00
cache_accept_custom_status_codes Put lycheecache tests into separate subfolders to avoid race 2023-03-03 12:13:09 +01:00
configs feat: raise error when the default config file is invalid (#1715) 2025-05-25 13:10:58 +02:00
dump_inputs feat: Add support for --dump-inputs (#1159) 2023-07-16 18:08:14 +02:00
exclude-path Add support for excluding paths from link checking (#623) 2022-05-29 17:27:09 +02:00
fallback-extensions Add a way to handle "pretty URLs", i.e. URIs without .html extension (#1422) 2024-06-11 16:11:24 +02:00
fragments feat: skip fragment checking for unsupported MIME types (#1744) 2025-07-06 10:46:06 +02:00
fragments-fallback-extensions fix: resolve index file inside a directory (#1752) 2025-07-03 16:55:57 +02:00
hidden/.hidden Test ignored files 2024-09-22 19:09:35 +02:00
ignore Test ignored files 2024-09-22 19:09:35 +02:00
lycheeignore Test ignored files 2024-09-22 19:09:35 +02:00
offline Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
resolve_paths Add support for relative links (#1489) 2024-10-26 04:07:37 +02:00
resolve_paths_from_root_dir/nested Introduce --root-dir (#1576) 2024-12-13 14:36:33 +01:00
INTERNET_ARCHIVE.md Concurrent archives (#1027) 2023-05-11 20:20:27 +02:00
LINK_PERIOD.html test: add tests for URL extraction ending with a period (#1641) 2025-02-24 08:48:58 +01:00
TEST.html Add new SVG-based screencast (#693) 2022-08-10 17:35:50 +02:00
TEST.md Introduce fragment checking for links to markdown files. (#1126) 2023-07-31 16:04:00 +02:00
TEST_ALL_PRIVATE.md feat: Support relative URLs (#15) 2020-10-21 01:31:06 +02:00
TEST_CODE_BLOCKS.md Implement excluding code blocks (#523) 2022-03-26 10:42:56 +01:00
TEST_DATA_URIS.html Add different verbosity levels (#824) 2022-11-28 23:25:33 +01:00
TEST_DETAILED_JSON_OUTPUT_ERROR.md Fix: Bring back error output for links (#1553) 2024-11-07 00:22:50 +01:00
TEST_DUMP_EXCLUDE.txt Also dump excluded links (#615) 2022-05-13 18:53:16 +02:00
TEST_EMAIL.md Make checking email addresses optional (#1171) 2023-07-19 19:58:38 +02:00
TEST_EMAIL_QUERY_PARAMS.html Fix parsing error of email addresses with query params (#809) 2022-11-05 23:40:33 +01:00
TEST_EMAIL_QUERY_PARAMS.md Fix parsing error of email addresses with query params (#809) 2022-11-05 23:40:33 +01:00
TEST_EXAMPLE_DOMAINS.md Exclude example TLDs from RFC 2606 (#1335) 2024-01-05 18:48:15 +01:00
TEST_EXAMPLE_DOMAINS_FALSE_POSITIVES.md Exclude example TLDs from RFC 2606 (#1335) 2024-01-05 18:48:15 +01:00
TEST_GITHUB.md Make GITHUB_TOKEN optional (#22) 2020-10-26 23:31:31 +01:00
TEST_GITHUB_404.md Make GITHUB_TOKEN optional (#22) 2020-10-26 23:31:31 +01:00
TEST_HTML5.html Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_HTML5_CUSTOM_ELEMENTS.html Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_HTML5_LOWERCASE_DOCTYPE.html Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_HTML5_MALFORMED_LINKS.html Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_HTML5_MINIFIED.html Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_HTTP.html Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_INVALID_URLS.html Fix: Bring back error output for links (#1553) 2024-11-07 00:22:50 +01:00
TEST_REPETITION_1.txt Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_REPETITION_2.txt Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_SCHEMES.md Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_SCHEMES.txt Prevent flaky tests (#514) 2022-02-18 10:29:49 +01:00
TEST_STYLESHEET_LINK.md Fix skipping of email addresses in stylesheets (#1546) 2024-10-27 01:32:11 +02:00
TEST_VERBATIM.html Fix nested URL extraction in verbatim elements (#988) 2023-03-11 15:18:25 +01:00