diff --git a/giturlparse/parser.py b/giturlparse/parser.py index f2c99e2..7475477 100644 --- a/giturlparse/parser.py +++ b/giturlparse/parser.py @@ -52,7 +52,9 @@ def parse(url, check_domain=True): parsed_info.update(platform.DEFAULTS) # Get matches as dictionary - matches = platform.clean_data(match.groupdict(default="")) + matches = platform.clean_data( + {k: v if v is not None else platform.DEFAULTS.get(k, "") for k, v in match.groupdict().items()} + ) # Update info with matches parsed_info.update(matches) diff --git a/giturlparse/platforms/bitbucket.py b/giturlparse/platforms/bitbucket.py index 51c1d54..aacefbf 100644 --- a/giturlparse/platforms/bitbucket.py +++ b/giturlparse/platforms/bitbucket.py @@ -4,7 +4,7 @@ class BitbucketPlatform(BasePlatform): PATTERNS = { "https": ( - r"(?P(git\+)?(?Phttps))://(?P<_user>.+)@(?P.+?)" + r"(?P(git\+)?(?Phttps))://(?:(?P<_user>.+)@)?(?P.+?)" r"(?P/(?P.+)/(?P.+?)(?:\.git)?)$" ), "ssh": ( @@ -16,5 +16,5 @@ class BitbucketPlatform(BasePlatform): "https": r"https://%(owner)s@%(domain)s/%(owner)s/%(repo)s%(dot_git)s", "ssh": r"git@%(domain)s:%(owner)s/%(repo)s%(dot_git)s", } - DOMAINS = ("bitbucket.org",) + DOMAINS = ("bitbucket.org", "bitbucket.com") DEFAULTS = {"_user": "git"} diff --git a/giturlparse/tests/test_parse.py b/giturlparse/tests/test_parse.py index cce43a1..bd9e70d 100644 --- a/giturlparse/tests/test_parse.py +++ b/giturlparse/tests/test_parse.py @@ -273,6 +273,75 @@ }, ), ), + ( + "HTTPS", + ( + "https://bitbucket.org/Org/Repo.git", + { + "host": "bitbucket.org", + "resource": "bitbucket.org", + "user": "git", + "port": "", + "owner": "Org", + "repo": "Repo", + "name": "Repo", + "groups": [], + "path": "", + "path_raw": "", + "pathname": "/Org/Repo.git", + "branch": "", + "protocol": "https", + "protocols": ["https"], + "platform": "bitbucket", + }, + ), + ), + ( + "HTTPS", + ( + "https://bitbucket.org/Org/Repo", + { + "host": "bitbucket.org", + "resource": "bitbucket.org", + "user": "git", + "port": "", + "owner": "Org", + "repo": "Repo", + "name": "Repo", + "groups": [], + "path": "", + "path_raw": "", + "pathname": "/Org/Repo", + "branch": "", + "protocol": "https", + "protocols": ["https"], + "platform": "bitbucket", + }, + ), + ), + ( + "HTTPS", + ( + "https://bitbucket.com/Org/Repo", + { + "host": "bitbucket.com", + "resource": "bitbucket.com", + "user": "git", + "port": "", + "owner": "Org", + "repo": "Repo", + "name": "Repo", + "groups": [], + "path": "", + "path_raw": "", + "pathname": "/Org/Repo", + "branch": "", + "protocol": "https", + "protocols": ["https"], + "platform": "bitbucket", + }, + ), + ), # Gitlab ( "SSH",