From c544efbcf33b90cc3da12fa51b07be9451ae95fe Mon Sep 17 00:00:00 2001 From: JonasDoesThings Date: Sat, 27 Jan 2024 20:32:37 +0100 Subject: [PATCH] fix: ignore external http(s) links in checks --- mkdocs_exclude_unused_files/plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mkdocs_exclude_unused_files/plugin.py b/mkdocs_exclude_unused_files/plugin.py index 0e20441..762dd73 100644 --- a/mkdocs_exclude_unused_files/plugin.py +++ b/mkdocs_exclude_unused_files/plugin.py @@ -147,10 +147,13 @@ def on_post_page(self, output: str, page: Page, config: MkDocsConfig) -> Optiona for tag, attr in html_tags.items(): for file in soup.find_all(tag, {attr: True}): + if unquote(file[attr]).startswith(("http://", "https://")): + continue + path_check = path.join(path.dirname(page.file.abs_dest_path), unquote(file[attr])) for suffix in self.config.file_name_suffixes_to_trim: if path_check.endswith(suffix): - path_check = path_check[:-len(suffix)] + path_check = path_check[: -len(suffix)] if path.exists(Path(path_check).resolve()): discarded_path = str(Path(path_check).resolve())