The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those.
Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation.
Solves: https://github.com/lycheeverse/lychee/issues/1599
Signed-off-by: MichaIng <micha@dietpi.com>
* windows
* Introduce --root-path
* lint
* lint
* Simplification
* Add unit tests
* Add integration test
* Sync docs
* Add missing comment to make CI happy
* Revert one of the Windows-specific changes because causing a test failure
* Support both options at the same time
* Revert a comment change that is no longer applicable
* Remove unused code
* Fix and simplification
* Integration test both at the same time
* Unit tests both at the same time
* Remove now redundant comment
* Revert windows-specific change, seems not needed after recent changes
* Use Collector::default()
* extract method and unit tests
* clippy
* clippy: &Option<A> -> Option<&A>
* Remove outdated comment
* Rename --root-path to --root-dir
* Restrict --root-dir to absolute paths for now
* Move root dir check
With the last lychee release, we simplified the status output for links.
While this reduced the visual noise, it also accidentally caused the source of errors to not be printed anymore. This change brings back the additional error information as part of the final report output. Furthermore, it shows the error information in the progress output if verbose mode is activated.
Fixes#1487
This commit introduces several improvements to the file checking process and URI handling:
- Extract file checking logic into separate `Checker` structs (`FileChecker`, `WebsiteChecker`, `MailChecker`)
- Improve handling of relative and absolute file paths
- Enhance URI parsing and creation from file paths
- Refactor `create_request` function for better clarity and error handling
These changes provide better support for resolving relative links, handling different base URLs, and working with file paths.
Fixes https://github.com/lycheeverse/lychee/issues/1296 and https://github.com/lycheeverse/lychee/issues/1480
This introduces an option `--cache-exclude-status`, which allows specifying a range of HTTP status codes which will be ignored from the cache.
Closes#1400.
Preconnect links are used to establish a server connection without loading a
specific resource yet. Not always do these links point to a URL that should
return a 200, and they are not user-facing, i.e. they don't show up in the
final rendered version of a page.
Therefore, we should not check them at all; not even in `--include-verbatim`
mode, as they might not point to a valid resource.
This turned out to require a significant overhaul of the html5gum extractor
to handle random attribute ordering correctly. Changes to the html5gum extractor:
* Refactor HTML link extractor for improved performance and maintainability
- Replace Vec<u8> with String for better readability and manipulation
- Introduce Element struct to encapsulate element-related data
- Use `HashMap<String, String>` for current_attributes for efficient lookups
- Add verbatim_stack to properly handle nested verbatim elements
- Remove unsafe code where possible, using String::from_utf8_lossy
- Improve attribute handling with `HashMap` entry API and prioritize `srcset`
- Simplify logic and consolidate verbatim element handling
- Enhance encapsulation in `LinkExtractor` struct
- Improve overall performance with more efficient data structures
- Increase flexibility for future feature additions or modifications
Fixes#897
This adds support for formatting responses in different ways.
For now, the options are:
* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons
Fixes#546
Related to #271
In many circumstances (GitHub Pages, Apache configured with MultiViews,
etc), web servers process URIs by appending the `.html` file extension
when no file is found at the path specified by the URI but a `.html`
file corresponding to that path _is_ found.
To allow Lychee to use the fast, offline method of checking such files
locally via the `file://` scheme, let's handle this scenario gracefully
by adding the `--fallback-extensions=html` option.
Note: This new option can take a list of file extensions to use; The
first one for which a corresponding file is found is then used.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Enclose Markdown links in brackets
The current clippy version (v0.1.78) says "you should put bare URLs
between `<`/`>` or make a proper Markdown link" and refers to
https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Enclose documentation item in backticks
Clippy v0.1.78 complains about the IPv6 network mask, insisting that it
is missing backticks. So backticks it gets.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Avoid error claiming `Add(usize)` is dead code
Clippy v0.1.78 identifies this as dead code. However, further down in
the same file, there is clearly a user:
impl Handler<Result, Result> for Add {
This might be yet another incarnation of
https://github.com/rust-lang/rust/issues/56750
Let's just mark it as intentionally dead-code, even if this is untrue,
to make clippy happy again.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---------
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
With the upgrade to `reqwest` 0.12, we can finally handle a long-standing
issue, when Urls could not be parsed to Uris. Previously, we would panic, but
we can now handle that situation gracefully and return an error instead.
I've also renamed `Status::is_failure` to `Status::is_error`, because the
notion of failures no longer exists in the codebase and we use the term "error"
consistently throughout the codebase instead. This is technically a breaking
change in the API, but it's fine since we have not released a stable version
yet.
More information about the URI parsing issue:
- https://github.com/lycheeverse/lychee/issues/539
- https://github.com/seanmonstar/reqwest/issues/668