From 00810bec75fb21925d33345ad12a805600915678 Mon Sep 17 00:00:00 2001 From: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com> Date: Thu, 16 Jul 2026 08:50:54 -0700 Subject: [PATCH] fix: handle trailing slash in repository URL --- dagshub/common/init.py | 1 + tests/common/test_init.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/dagshub/common/init.py b/dagshub/common/init.py index 86fad2d4..3a53e761 100644 --- a/dagshub/common/init.py +++ b/dagshub/common/init.py @@ -76,6 +76,7 @@ def init( repo, branch = determine_repo(root) url = repo.repo_url + url = url.rstrip("/") if url.endswith(".git"): url = url[:-4] # Extract the owner and name from the repo_url diff --git a/tests/common/test_init.py b/tests/common/test_init.py index 226d9a71..dc4d8f17 100644 --- a/tests/common/test_init.py +++ b/tests/common/test_init.py @@ -74,6 +74,15 @@ def test_init_creates_repo_under_current_user_from_url( ) +def test_init_from_url_ignores_trailing_slash( + mock_repo_api, mock_user_api, mock_create_repo, mock_get_token, mock_log_message +): + dagshub.init(url="https://dagshub.com/testuser/my-repo/", mlflow=False, dvc=False) + + mock_repo_api.assert_called_once_with("testuser/my-repo", host="https://dagshub.com") + mock_create_repo.assert_called_once_with("my-repo", host="https://dagshub.com") + + def test_init_creates_repo_under_org_from_url( mock_repo_api, mock_user_api, mock_create_repo, mock_get_token, mock_log_message ):