Commit graph

41 commits

Author SHA1 Message Date
Marcel
c0dd38b234 Speedup "zola check" command by reusing the Client (#2171)
* Reuse Client when checking urls and add timeout for requests
2023-12-18 23:24:06 +01:00
Vincent Prouillet
a0630efb76 Rename links utils mod 2022-05-02 22:07:47 +02:00
Vincent Prouillet
9ab1bf2e4e
Re-organise content and remove slotmap indirection level (#1827) 2022-04-26 20:51:04 +02:00
Vincent Prouillet
c11ae6ef28
Use anyhow (#1816)
Also fixes #1783
2022-04-01 21:37:38 +02:00
Vincent Prouillet
2feda3ec61 Update deps 2022-03-04 21:36:35 +01:00
Sam Vente
dde3531fd9
Make sure that zola serve/build can start from anywhere inside dir tree (#1761)
* Make sure that zola serve/build can start from anywhere inside dir tree

* make clippy and rustfmt a bit happier

* replace unecessary if-else with unwrap_or and display which path could not get canonicalized if it fails at startup

* canonicalize config_path to avoid crash when config.toml changes
2022-03-03 12:35:29 +01:00
Vincent Prouillet
ae3a8b802e Add libs subcrate (#1747)
* Add libs subcrate

* Remove last direct lazy_static usage

* Update pinned ci version

* Update deps
2022-02-14 11:08:40 +01:00
Phil Lord
5190b5eba5 Add heuristic checking for HTML anchors (#1716)
* Add heuristic checking for HTML anchors

Previously only anchors specified or generated in markdown could be
linked to, without complaint from the link checker. We now use a
simple heuristic check for `name` or `id` attributes.

Duplicate code has been refactored and all XML anchor checks updated
to use regex rather than substring match.

* Fix regexp and refactor
2022-01-23 14:33:51 +01:00
liushuyu
c658d171f8
cargo/manifests: allow user to use native-tls if ring is unsupported (#1587)
* cargo/manifests: allow user to use native-tls ...

... if `ring` can't be used on the user's platform (e.g. mips/ppc/riscv)

* CI: test for native tls build
2021-08-18 15:32:34 +02:00
Vincent Prouillet
e92e4f1003 Tweaks to load_data + update deps 2021-04-21 21:43:02 +02:00
Vincent Prouillet
8e6c3f4fef Update changelog + deps 2021-02-02 20:25:27 +01:00
Vincent Prouillet
877f441422 Update reqwest 2021-01-05 22:11:15 +01:00
Vincent Prouillet
92282608fe Update changelog 2020-12-14 20:43:31 +01:00
Nathan West
51a2213fcf
Replaced all impl Default with derive(Default), where possible (#1141) 2020-08-19 12:25:54 +02:00
Vincent Prouillet
ffaf5e04b8 Do not unwrap on invalid utf8 in link checker
Closes #1134
2020-08-17 18:58:08 +02:00
Tuomas Siipola
4a3c1568a2
Support anchors without quotes in link checker (#1118)
* Support anchors without quotes in link checker

Not widely used but in many cases quotes in attributes are optional.

* Fix duplicate test
2020-08-07 17:02:02 +02:00
Vincent Prouillet
b4c5e9a34a Update changelog 2020-07-29 20:49:15 +02:00
Vincent Prouillet
9f20af1521 Update deps 2020-07-22 18:59:21 +02:00
Vincent Prouillet
fbf431d612 Update syntect, using rust-onig with bindgen temporarily 2020-05-12 20:07:02 +02:00
Sven-Hendrik Haase
e9b47dae59
Remove implicit dependency on openssl-sys (#1001) (#1005) 2020-04-27 09:49:05 +02:00
Vincent Prouillet
b96b187eca Fix tests + rustfmt 2020-04-22 10:07:17 +02:00
Andrew Wonnacott
d19855e909
Rewrite link_checker to use a Result internally (#928) 2020-04-22 10:04:10 +02:00
Vincent Prouillet
91bf91a88b Fix link checker not checking for capital id/name
Closes #948
2020-03-25 19:54:24 +01:00
Luke Hsiao
661bd9c0fa Set default user agent for external requests
Many servers will return errors (e.g. 400/403) to requests that do not
set a User-Agent header. This results in issues in both the link_checker
and load_data components. With the link_checker these are false positive
dead links. In load_data, remote data fails to be fetched. To mitigate
this issue, this sets a default User-Agent of

    $CARGO_PKG_NAME/$CARGO_PKG_VERSION

Note that the root cause of this regression from zola v0.9.0 is that
reqwest 0.10 changed their default behavior and no longer sets a
User-Agent by default:

    https://github.com/seanmonstar/reqwest/pull/751

Fixes #950.
2020-02-17 17:40:06 -08:00
Vincent Prouillet
15a3ab1a51 One last deps update 2020-02-16 19:17:41 +01:00
Vincent Prouillet
a903473a87 Use rustls reqwest feature 2020-02-07 21:16:44 +01:00
djugei
046213ce28 fixed warning (#912) 2020-02-02 17:48:43 -08:00
Sam Ford
d7bad732f1 Update reqwest to v0.10 (#892) 2020-02-02 17:48:43 -08:00
Sam Ford
6b5768fd76 Treat 304 as valid, add mock tests, fix mock issue (#900)
* Treat 304 (Not Modified) requests as valid.

* Add tests for 301-to-200 links, 301-to-404 links, and 500 links.
This helps to test redirections and the previously-added
response.status() checking for non-success status codes in check_url().

* Make names for HTTP mock paths unique, to avoid weird behavior. It
seems like mocks with the same path can potentially bleed between
tests, so you may end up with an unexpected response which causes the
test to sometimes pass and sometimes fail.

* Fix Clippy warnings about String::from(format!()).
2020-02-02 17:48:43 -08:00
Sam Ford
11f7a6d114 Mock HTTP requests in tests (#898)
Certain tests involving HTTP requests were sometimes hanging
indefinitely, so this uses Mockito for HTTP mocking. This seemingly
resolves the issue and makes these tests more reliable.

The existing can_fail_404_links test has been renamed to
can_fail_unresolved_links, to represent what actually occurs in the
test. The can_fail_404_links test now deals with a proper 404
response.

Just to be clear, the check_site test in the site component will
still create outgoing HTTP requests (due to the URLs used in the
test_site), so this commit only uses HTTP mocking where possible.
2020-02-02 17:48:43 -08:00
Sam Ford
2f1b592ab4 link_checker: Handle non-success status codes (#897)
The can_fail_404_links() test doesn't encounter a 404 response in
actuality, since the google.comys domain doesn't resolve. When the
test is updated such that the response's status code is a 404, the
test fails because the check_url() function doesn't handle
non-success responses how the test's assertions expect. This commit
updates check_url() to handle non-success responses, treating them
much like errors.
2020-02-02 17:48:43 -08:00
Sam Ford
e804f907b2 Use Rust 2018 edition (#885) 2020-02-02 17:48:43 -08:00
Tjeu Kayim
75570d041a Skip link checking for URL with prefix in config (#846) 2020-02-02 17:47:01 -08:00
Tjeu Kayim
6149fd17e1 Skip anchor checking for URL with prefix in config (#812)
* cargo fmt & clippy

* Skip anchor checking for URL with prefix in config
2020-02-02 17:45:16 -08:00
Neil Kistner
52c2b74b39 Add anchor existence checking to link_checker component (#786)
* Add anchor existant checking to link_checker component

* Oops, forgot some changes

* Drop scraper dependency and rework tests

* Handle name attributes
2019-09-04 20:31:19 +02:00
Vincent Prouillet
b7ce4e59fb rustfmt 2018-10-31 08:18:57 +01:00
Vincent Prouillet
9dca46cfd3 Correct usage of reqwest headers 2018-09-30 20:20:26 +02:00
Vincent Prouillet
f5c88540ed Update reqwest and image 2018-09-30 19:17:51 +02:00
Thomas Hurst
6a5ace62fc link_checker: Set Accept header
As mentioned in #381, crates.io 404's any request without an Accept:
text/html header.  It 200's any request with one, but at least
false-successes don't prevent checking any other links.

This also makes it easier to add a custom User-Agent if desired.

rustfmt and fix a clippy nit (unnecessary return) while I'm here.
2018-08-25 17:17:06 +01:00
Vincent Prouillet
60a52fd2cc Some intellij reformatting 2018-07-31 15:30:49 +02:00
Vincent Prouillet
3e48ff24b5 Add an external link checker
Close #115
2018-07-16 21:15:50 +02:00