Skip to content

Commit d344357

Browse files
author
Eirikr
committed
Fix crash when edit_uri is not defined
1 parent a44dd58 commit d344357

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

mkdocs_multirepo_plugin/structure.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ def _fix_edit_uri(self, edit_uri: str) -> str:
241241
# Mkdocs by default sets the edit_uri to 'edit/master/docs/' when the repo_url is GitHub and
242242
# 'src/default/docs/' when it's Bitbucket. We don't want docs to be in the edit_uri since
243243
# documentation isn't always in the docs directory for this plugin.
244+
245+
if not edit_uri:
246+
return ""
244247
edit_uri_parts = edit_uri.strip("/").split("/")
245248
parts = len(edit_uri_parts)
246249
if parts > 1 and edit_uri_parts[1] == "master" and self.branch != "master":

tests/unittests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,17 @@ def test_parse_repo_url(self):
280280
f"{base_url}?docs_dir=fldr/docs/*?config=multirepo.yml"
281281
)
282282

283+
def test_edit_uri_none(self):
284+
repo = structure.DocsRepo(
285+
name="test-repo",
286+
url="https://github.com/jdoiro3/mkdocs-multirepo-demoRepo1",
287+
temp_dir=pathlib.Path("."),
288+
branch="main",
289+
edit_uri=None
290+
)
291+
292+
self.assertEqual(repo.edit_uri, "")
293+
283294
async def test_sparse_clone(self):
284295
async with tempfile.TemporaryDirectory() as temp_dir:
285296
temp_dir_path = pathlib.Path(temp_dir)

0 commit comments

Comments
 (0)