renamed base to base_url (fixes #1607) (#1629)

* renamed `base` to `base_url` (fixes #1607)
* fixed readme
* added warning for deprecated `--base`
* Update lychee.example.toml
* Update fixtures/configs/smoketest.toml
This commit is contained in:
Ben 2025-02-16 01:41:32 +01:00 committed by GitHub
parent 50687175d1
commit d6bbf85145
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 12 deletions

View file

@ -484,8 +484,11 @@ Options:
[default: get]
-b, --base <BASE>
Base URL or website root directory to check relative URLs e.g. <https://example.com> or `/path/to/public`
--base <BASE>
Deprecated; use `--base-url` instead
-b, --base-url <BASE_URL>
Base URL used to resolve relative URLs during link checking Example: <https://example.com>
--root-dir <ROOT_DIR>
Root path to use when checking absolute local links, must be an absolute path

View file

@ -80,7 +80,7 @@ remap = [
]
# Base URL or website root directory to check relative URLs.
base = "https://example.com"
base_url = "https://example.com"
# HTTP basic auth support. This will be the username and password passed to the
# authorization HTTP header. See

View file

@ -55,7 +55,7 @@ pub(crate) fn create(cfg: &Config, cookie_jar: Option<&Arc<CookieStoreMutex>>) -
ClientBuilder::builder()
.remaps(remaps)
.base(cfg.base.clone())
.base(cfg.base_url.clone())
.includes(includes)
.excludes(excludes)
.exclude_all_private(cfg.exclude_all_private)

View file

@ -177,6 +177,13 @@ fn load_config() -> Result<LycheeOptions> {
warn!("WARNING: `--exclude-mail` is deprecated and will soon be removed; E-Mail is no longer checked by default. Use `--include-mail` to enable E-Mail checking.");
}
// TODO: Remove this warning and the parameter with 1.0
if opts.config.base.is_some() {
warn!(
"WARNING: `--base` is deprecated and will soon be removed; use `--base-url` instead."
);
}
// Load excludes from file
for path in &opts.config.exclude_file {
let file = File::open(path)?;
@ -288,7 +295,18 @@ fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {
async fn run(opts: &LycheeOptions) -> Result<i32> {
let inputs = opts.inputs()?;
let mut collector = Collector::new(opts.config.root_dir.clone(), opts.config.base.clone())?
// TODO: Remove this section after `--base` got removed with 1.0
let base = match (opts.config.base.clone(), opts.config.base_url.clone()) {
(None, None) => None,
(Some(base), None) => Some(base),
(None, Some(base_url)) => Some(base_url),
(Some(_base), Some(base_url)) => {
warn!("WARNING: Both, `--base` and `--base-url` are set. Using `base-url` and ignoring `--base` (as it's deprecated).");
Some(base_url)
}
};
let mut collector = Collector::new(opts.config.root_dir.clone(), base)?
.skip_missing_inputs(opts.config.skip_missing)
.skip_hidden(!opts.config.hidden)
.skip_ignored(!opts.config.no_ignore)

View file

@ -449,11 +449,16 @@ separated list of accepted status codes. This example will accept 200, 201,
#[serde(default = "method")]
pub(crate) method: String,
/// Base URL or website root directory to check relative URLs
/// e.g. <https://example.com> or `/path/to/public`
/// Deprecated; use `--base-url` instead
#[arg(long, value_parser = parse_base)]
#[serde(skip)]
pub(crate) base: Option<Base>,
/// Base URL used to resolve relative URLs during link checking
/// Example: <https://example.com>
#[arg(short, long, value_parser= parse_base)]
#[serde(default)]
pub(crate) base: Option<Base>,
pub(crate) base_url: Option<Base>,
/// Root path to use when checking absolute local links,
/// must be an absolute path
@ -568,7 +573,7 @@ impl Config {
timeout: DEFAULT_TIMEOUT_SECS;
retry_wait_time: DEFAULT_RETRY_WAIT_TIME_SECS;
method: DEFAULT_METHOD;
base: None;
base_url: None;
basic_auth: None;
skip_missing: false;
include_verbatim: false;

View file

@ -383,7 +383,7 @@ mod cli {
let dir = fixtures_path().join("resolve_paths");
cmd.arg("--offline")
.arg("--base")
.arg("--base-url")
.arg(&dir)
.arg(dir.join("index.html"))
.env_clear()
@ -419,7 +419,7 @@ mod cli {
cmd.arg("--offline")
.arg("--root-dir")
.arg("/resolve_paths")
.arg("--base")
.arg("--base-url")
.arg(&dir)
.arg(dir.join("resolve_paths").join("index.html"))
.env_clear()

View file

@ -75,7 +75,7 @@ header = ["name=value", "other=value"]
remap = ["https://example.com http://example.invalid"]
# Base URL or website root directory to check relative URLs.
base = "https://example.com"
base_url = "https://example.com"
# HTTP basic auth support. This will be the username and password passed to the
# authorization HTTP header. See