Skip to content

Commit 0087274

Browse files
CM-57660-Fix tests
1 parent f0df95e commit 0087274

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

cycode/cli/utils/url_utils.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ def sanitize_repository_url(url: Optional[str]) -> Optional[str]:
3232
if not url:
3333
return url
3434

35-
# Handle SSH URLs (git@host:path format) - no credentials to remove
36-
if '@' in url and '://' not in url and url.startswith(('git@', 'ssh://')):
35+
# Handle SSH URLs - no credentials to remove
36+
# ssh:// URLs have the format ssh://git@host/path
37+
if url.startswith('ssh://'):
38+
return url
39+
# git@host:path format (scp-style)
40+
if '@' in url and '://' not in url and url.startswith('git@'):
3741
return url
3842

3943
try:
@@ -44,15 +48,16 @@ def sanitize_repository_url(url: Optional[str]) -> Optional[str]:
4448
if parsed.port:
4549
sanitized_netloc = f'{sanitized_netloc}:{parsed.port}'
4650

47-
sanitized = urlunparse((
48-
parsed.scheme,
49-
sanitized_netloc,
50-
parsed.path,
51-
parsed.params,
52-
parsed.query,
53-
parsed.fragment,
54-
))
55-
return sanitized
51+
return urlunparse(
52+
(
53+
parsed.scheme,
54+
sanitized_netloc,
55+
parsed.path,
56+
parsed.params,
57+
parsed.query,
58+
parsed.fragment,
59+
)
60+
)
5661
except Exception as e:
5762
logger.debug('Failed to sanitize repository URL, returning original, %s', {'url': url, 'error': str(e)})
5863
# If parsing fails, return original URL to avoid breaking functionality

tests/utils/test_url_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
from cycode.cli.utils.url_utils import sanitize_repository_url
42

53

0 commit comments

Comments
 (0)