Skip to content

Commit c1d49d1

Browse files
committed
Fixed authentication for Git repository URLs
1 parent c3259cc commit c1d49d1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mbed/mbed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
regex_url_ref = r'^(.*/([\w.+-]+)(?:\.\w+)?)/?(?:#(.*))?$'
9898

9999
# git url (no #rev)
100-
regex_git_url = r'^(git@|git\://|ssh\://|https?\://)([^/:]+)[:/](.+?)(\.git|\/?)$'
100+
regex_git_url = r'^(git\://|ssh\://|https?\://|)(([^/:@]+)(\:([^/:@]+))?@)?([^/:]+)[:/](.+?)(\.git|\/?)$'
101101
# hg url (no #rev)
102102
regex_hg_url = r'^(file|ssh|https?)://([^/:]+)/([^/]+)/?([^/]+?)?$'
103103

@@ -1376,11 +1376,11 @@ def formaturl(url, format="default"):
13761376
m = re.match(regex_git_url, url)
13771377
if m:
13781378
if format == "ssh":
1379-
url = 'ssh://git@%s/%s.git' % (m.group(2), m.group(3))
1379+
url = 'ssh://%s%s/%s.git' % (m.group(2) or 'git@', m.group(6), m.group(7))
13801380
elif format == "http":
1381-
url = 'http://%s/%s' % (m.group(2), m.group(3))
1381+
url = 'http://%s%s/%s' % (m.group(2) if m.group(5) or m.group(3) != 'git' else '', m.group(6), m.group(7))
13821382
elif format == "https":
1383-
url = 'https://%s/%s' % (m.group(2), m.group(3))
1383+
url = 'https://%s%s/%s' % (m.group(2) if m.group(5) or m.group(3) != 'git' else '', m.group(6), m.group(7))
13841384
else:
13851385
m = re.match(regex_hg_url, url)
13861386
if m:

0 commit comments

Comments
 (0)