Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/configs/smoketest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lychee-bin/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion lychee-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions lychee-bin/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lychee-bin/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lychee.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down