From a31a8cdbab2bd98cb8de3408c67f549a96598eca Mon Sep 17 00:00:00 2001 From: Suraj Jadhav Date: Sat, 7 Feb 2026 21:57:40 +0100 Subject: [PATCH] fix: handle empty URL parts in edit_uri to prevent TypeError `__get_page_dir_alias` crashes with `TypeError: join() missing 1 required positional argument` when processing root-level pages (e.g. `index.md`). The page URL splits into parts that become empty after popping, and `path.join(*parts)` fails on an empty list. Guard the loop to terminate when parts is exhausted, and return None when no alias matches. In `build()`, fall back to the page's default edit_url when no alias is found. Fixes #131 Co-Authored-By: Claude Opus 4.6 --- mkdocs_monorepo_plugin/edit_uri.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkdocs_monorepo_plugin/edit_uri.py b/mkdocs_monorepo_plugin/edit_uri.py index 8845ec3..24adc5a 100644 --- a/mkdocs_monorepo_plugin/edit_uri.py +++ b/mkdocs_monorepo_plugin/edit_uri.py @@ -32,11 +32,12 @@ def __get_root_docs_dir(self): def __get_page_dir_alias(self): parts = self.page.url.split("/") - while True: + while parts: parts.pop() - alias = path.join(*parts) + alias = path.join(*parts) if parts else "" if alias in self.plugin.aliases: return alias + return None def __get_page_docs_dir(self): alias = self.__get_page_dir_alias() @@ -102,6 +103,8 @@ def __is_root(self): def build(self): if self.__is_root(): return self.page.edit_url + if self.__get_page_dir_alias() is None: + return self.page.edit_url if self.__has_repo(): config = self.__get_page_config_file_yaml() return config["repo_url"] + config["edit_uri"] + self.__get_page_src_path()