From 00ddb6dfc8df2744b98908362f06384dac933d70 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 6 Sep 2021 00:35:11 +0200 Subject: [PATCH] Filter out directories with suffixes that look like extensions Directories can still have a suffix which looks like a file extension like `foo.html`. This can lead to unexpected behavior with glob patterns like `**/*.html`. Therefore filter these out. https://github.com/lycheeverse/lychee/pull/262#issuecomment-91322681 --- lychee-lib/src/types/input.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lychee-lib/src/types/input.rs b/lychee-lib/src/types/input.rs index ad5ed83..ad97355 100644 --- a/lychee-lib/src/types/input.rs +++ b/lychee-lib/src/types/input.rs @@ -161,6 +161,14 @@ impl Input { for entry in glob_with(&glob_expanded, match_opts)? { match entry { Ok(path) => { + if path.is_dir() { + // Directories can still have a suffix which looks like + // a file extension like `foo.html`. This can lead to + // unexpected behavior with glob patterns like + // `**/*.html`. Therefore filter these out. + // https://github.com/lycheeverse/lychee/pull/262#issuecomment-913226819 + continue; + } let content = Self::path_content(&path)?; contents.push(content); }