mirror of
https://github.com/Hopiu/lychee.git
synced 2026-03-16 20:50:25 +00:00
Update flag description & clean up
This commit is contained in:
parent
002fa49f29
commit
5036ce8388
6 changed files with 9 additions and 74 deletions
|
|
@ -424,13 +424,13 @@ Options:
|
||||||
URLs to check (supports regex). Has preference over all excludes
|
URLs to check (supports regex). Has preference over all excludes
|
||||||
|
|
||||||
--exclude <EXCLUDE>
|
--exclude <EXCLUDE>
|
||||||
Exclude URLs and mail addresses from checking (supports regex)
|
Exclude URLs and mail addresses from checking. The values are treated as regular expressions
|
||||||
|
|
||||||
--exclude-file <EXCLUDE_FILE>
|
--exclude-file <EXCLUDE_FILE>
|
||||||
Deprecated; use `--exclude-path` instead
|
Deprecated; use `--exclude-path` instead
|
||||||
|
|
||||||
--exclude-path <EXCLUDE_PATH>
|
--exclude-path <EXCLUDE_PATH>
|
||||||
Exclude file path from getting checked
|
Exclude paths from getting checked. The values are treated as regular expressions
|
||||||
|
|
||||||
-E, --exclude-all-private
|
-E, --exclude-all-private
|
||||||
Exclude all private IPs from checking.
|
Exclude all private IPs from checking.
|
||||||
|
|
|
||||||
4
fixtures/configs/smoketest.toml
vendored
4
fixtures/configs/smoketest.toml
vendored
|
|
@ -99,10 +99,10 @@ include_verbatim = false
|
||||||
# Ignore case of paths when matching glob patterns.
|
# Ignore case of paths when matching glob patterns.
|
||||||
glob_ignore_case = false
|
glob_ignore_case = false
|
||||||
|
|
||||||
# Exclude URLs and mail addresses from checking (supports regex).
|
# Exclude URLs and mail addresses from checking. The values are treated as regular expressions
|
||||||
exclude = ['.*\.github.com\.*']
|
exclude = ['.*\.github.com\.*']
|
||||||
|
|
||||||
# Exclude these filesystem paths from getting checked.
|
# Exclude paths from getting checked. The values are treated as regular expressions
|
||||||
exclude_path = ["file/path/to/Ignore", "./other/file/path/to/Ignore"]
|
exclude_path = ["file/path/to/Ignore", "./other/file/path/to/Ignore"]
|
||||||
|
|
||||||
# URLs to check (supports regex). Has preference over all excludes.
|
# URLs to check (supports regex). Has preference over all excludes.
|
||||||
|
|
|
||||||
|
|
@ -505,7 +505,7 @@ and 501."
|
||||||
pub(crate) include: Vec<String>,
|
pub(crate) include: Vec<String>,
|
||||||
|
|
||||||
/// Exclude URLs and mail addresses from checking.
|
/// Exclude URLs and mail addresses from checking.
|
||||||
/// The value is treated as regular expression.
|
/// The values are treated as regular expressions.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) exclude: Vec<String>,
|
pub(crate) exclude: Vec<String>,
|
||||||
|
|
@ -516,7 +516,7 @@ and 501."
|
||||||
pub(crate) exclude_file: Vec<String>,
|
pub(crate) exclude_file: Vec<String>,
|
||||||
|
|
||||||
/// Exclude paths from getting checked.
|
/// Exclude paths from getting checked.
|
||||||
/// The value is treated as regular expression.
|
/// The values are treated as regular expressions.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) exclude_path: Vec<String>,
|
pub(crate) exclude_path: Vec<String>,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use super::file::FileExtensions;
|
||||||
use super::resolver::UrlContentResolver;
|
use super::resolver::UrlContentResolver;
|
||||||
use crate::filter::PathExcludes;
|
use crate::filter::PathExcludes;
|
||||||
use crate::types::FileType;
|
use crate::types::FileType;
|
||||||
use crate::{ErrorKind, Result, utils};
|
use crate::{ErrorKind, Result};
|
||||||
use async_stream::try_stream;
|
use async_stream::try_stream;
|
||||||
use futures::stream::Stream;
|
use futures::stream::Stream;
|
||||||
use glob::glob_with;
|
use glob::glob_with;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ use crate::{ErrorKind, Result};
|
||||||
use cached::proc_macro::cached;
|
use cached::proc_macro::cached;
|
||||||
use path_clean::PathClean;
|
use path_clean::PathClean;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
|
@ -51,26 +50,6 @@ pub(crate) fn resolve(
|
||||||
Ok(Some(absolute_path(resolved)))
|
Ok(Some(absolute_path(resolved)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if `child` is a subdirectory/file inside `parent`
|
|
||||||
///
|
|
||||||
/// Note that `contains(parent, parent)` will return `true`
|
|
||||||
///
|
|
||||||
/// See <https://stackoverflow.com/questions/30511331>
|
|
||||||
/// See <https://stackoverflow.com/questions/62939265>
|
|
||||||
///
|
|
||||||
/// # Errors
|
|
||||||
///
|
|
||||||
/// Returns an error if the `path` does not exist
|
|
||||||
/// or a non-final component in path is not a directory.
|
|
||||||
//
|
|
||||||
// Unfortunately requires real files for `fs::canonicalize`.
|
|
||||||
pub(crate) fn contains(parent: &PathBuf, child: &PathBuf) -> Result<bool> {
|
|
||||||
let parent = fs::canonicalize(parent)?;
|
|
||||||
let child = fs::canonicalize(child)?;
|
|
||||||
|
|
||||||
Ok(child.starts_with(parent))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_path {
|
mod test_path {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -114,48 +93,4 @@ mod test_path {
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_contains() {
|
|
||||||
let parent_dir = tempfile::tempdir().unwrap();
|
|
||||||
let parent = parent_dir.path();
|
|
||||||
let child_dir = tempfile::tempdir_in(parent).unwrap();
|
|
||||||
let child = child_dir.path();
|
|
||||||
|
|
||||||
assert_eq!(contains(&parent.to_owned(), &child.to_owned()), Ok(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_contains_not() {
|
|
||||||
let dir1 = tempfile::tempdir().unwrap();
|
|
||||||
let dir2 = tempfile::tempdir().unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
contains(&dir1.path().to_owned(), &dir2.path().to_owned()),
|
|
||||||
Ok(false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_contains_one_dir_does_not_exist() {
|
|
||||||
let dir1 = tempfile::tempdir().unwrap();
|
|
||||||
|
|
||||||
assert!(matches!(
|
|
||||||
contains(&dir1.path().to_owned(), &PathBuf::from("/does/not/exist")),
|
|
||||||
Err(crate::ErrorKind::ReadStdinInput(_))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relative paths are supported, e.g.
|
|
||||||
// parent: `/path/to/parent`
|
|
||||||
// child: `/path/to/parent/child/..`
|
|
||||||
#[test]
|
|
||||||
fn test_contains_one_dir_relative_path() {
|
|
||||||
let parent_dir = tempfile::tempdir().unwrap();
|
|
||||||
let parent = parent_dir.path();
|
|
||||||
let child_dir = tempfile::tempdir_in(parent).unwrap();
|
|
||||||
let child = child_dir.path().join("..");
|
|
||||||
|
|
||||||
assert_eq!(contains(&parent.to_owned(), &child), Ok(true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,10 +104,10 @@ include_verbatim = false
|
||||||
# Ignore case of paths when matching glob patterns.
|
# Ignore case of paths when matching glob patterns.
|
||||||
glob_ignore_case = false
|
glob_ignore_case = false
|
||||||
|
|
||||||
# Exclude URLs and mail addresses from checking (supports regex).
|
# Exclude URLs and mail addresses from checking. The values are treated as regular expressions
|
||||||
exclude = ['^https://www\.linkedin\.com', '^https://web\.archive\.org/web/']
|
exclude = ['^https://www\.linkedin\.com', '^https://web\.archive\.org/web/']
|
||||||
|
|
||||||
# Exclude these filesystem paths from getting checked.
|
# Exclude paths from getting checked. The values are treated as regular expressions
|
||||||
exclude_path = ["file/path/to/Ignore", "./other/file/path/to/Ignore"]
|
exclude_path = ["file/path/to/Ignore", "./other/file/path/to/Ignore"]
|
||||||
|
|
||||||
# URLs to check (supports regex). Has preference over all excludes.
|
# URLs to check (supports regex). Has preference over all excludes.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue