Skip to content

Commit

Permalink
Merge pull request #153 from johnmhoran/143-add-purl2url-cocoapods-re…
Browse files Browse the repository at this point in the history
…po-url-support

Add repo URL support and testing for cocoapods
  • Loading branch information
JonoYang committed Aug 12, 2024
2 parents f98abf0 + 7ebe681 commit 04a706a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/packageurl/contrib/purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ 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
return name and f"https://cocoapods.org/pods/{name}"


# Download URLs:


Expand Down
3 changes: 3 additions & 0 deletions tests/contrib/test_purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def test_purl2url_get_repo_url():
"pkg:golang/xorm.io/xorm": "https://pkg.go.dev/xorm.io/xorm",
"pkg:golang/xorm.io/xorm@v0.8.2": "https://pkg.go.dev/xorm.io/xorm@v0.8.2",
"pkg:golang/gopkg.in/ldap.v3@v3.1.0": "https://pkg.go.dev/gopkg.in/ldap.v3@v3.1.0",
"pkg:cocoapods/AFNetworking@4.0.1": "https://cocoapods.org/pods/AFNetworking",
"pkg:cocoapods/MapsIndoors@3.24.0": "https://cocoapods.org/pods/MapsIndoors",
}

for purl, url in purls_url.items():
Expand Down Expand Up @@ -143,6 +145,7 @@ def test_purl2url_get_inferred_urls():
"https://gitlab.com/tg1999/firebase/-/archive/1a122122/firebase-1a122122.tar.gz",
],
"pkg:pypi/sortedcontainers@2.4.0": ["https://pypi.org/project/sortedcontainers/2.4.0/"],
"pkg:cocoapods/AFNetworking@4.0.1": ["https://cocoapods.org/pods/AFNetworking"],
"pkg:composer/psr/log@1.1.3": ["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 04a706a

Please sign in to comment.