Skip to content

Commit

Permalink
Add repo URL support and testing for cocoapods package-url#143
Browse files Browse the repository at this point in the history
Reference: package-url#143

Signed-off-by: John M. Horan <[email protected]>
  • Loading branch information
johnmhoran committed Apr 8, 2024
1 parent ef3747a commit 4bd76d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/packageurl/contrib/purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ def build_golang_repo_url(purl):
return f"https://pkg.go.dev/{namespace}/{name}"


@repo_router.route("pkg:cocoapods/.*")
def build_cocoapods_repo_url(purl):
"""
Return a CocoaPods repo URL from the `purl` string.
"""
purl_data = PackageURL.from_string(purl)
name = purl_data.name

if name:
repository_homepage_url = f"https://cocoapods.org/pods/{name}"

return repository_homepage_url


# Download URLs:


Expand Down
7 changes: 6 additions & 1 deletion tests/contrib/test_purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def test_purl2url_get_repo_url():
"pkg:golang/xorm.io/xorm": "https://pkg.go.dev/xorm.io/xorm",
"pkg:golang/xorm.io/[email protected]": "https://pkg.go.dev/xorm.io/[email protected]",
"pkg:golang/gopkg.in/[email protected]": "https://pkg.go.dev/gopkg.in/[email protected]",
"pkg:cocoapods/[email protected]": "https://cocoapods.org/pods/AFNetworking",
"pkg:cocoapods/[email protected]": "https://cocoapods.org/pods/MapsIndoors",
}

for purl, url in purls_url.items():
Expand Down Expand Up @@ -134,7 +136,10 @@ def test_purl2url_get_inferred_urls():
"https://gitlab.com/tg1999/firebase",
"https://gitlab.com/tg1999/firebase/-/archive/1a122122/firebase-1a122122.tar.gz",
],
"pkg:pypi/[email protected]": ["https://pypi.org/project/sortedcontainers/2.4.0/"],
"pkg:pypi/[email protected]": [
"https://pypi.org/project/sortedcontainers/2.4.0/"
],
"pkg:cocoapods/[email protected]": ["https://cocoapods.org/pods/AFNetworking"],
"pkg:composer/psr/[email protected]": ["https://packagist.org/packages/psr/log#1.1.3"],
"pkg:rubygems/package-name": ["https://rubygems.org/gems/package-name"],
"pkg:bitbucket/birkenfeld": [],
Expand Down

0 comments on commit 4bd76d5

Please sign in to comment.