diff --git a/manifest_xml.py b/manifest_xml.py index edbebaa3..7e533a02 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -134,7 +134,7 @@ def normalize_url(url: str) -> str: parsed_url = urllib.parse.urlparse(url) # This matches patterns like "git@github.com:foo/bar". - scp_like_url_re = r"^[^:]+@[^:]+:[^/]+/" + scp_like_url_re = r"^[^/:]+@[^/:]+:[^/]+/" # If our URL is missing a schema and matches git's # SCP-like syntax we should convert it to a proper diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 11c0c15e..6423bb96 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -1139,6 +1139,17 @@ class NormalizeUrlTests(ManifestParseTestCase): "http://foo.com/bar/baz", manifest_xml.normalize_url(url) ) + def test_has_leading_slash(self): + """SCP-like syntax except a / comes before the : which git disallows.""" + url = "/git@foo.com:bar/baf" + self.assertEqual(url, manifest_xml.normalize_url(url)) + + url = "gi/t@foo.com:bar/baf" + self.assertEqual(url, manifest_xml.normalize_url(url)) + + url = "git@fo/o.com:bar/baf" + self.assertEqual(url, manifest_xml.normalize_url(url)) + def test_has_no_scheme(self): """Deal with cases where we have no scheme, but we also aren't dealing with the git SCP-like syntax