Skip to content

Commit 04a706a

Browse files
authored
Merge pull request #153 from johnmhoran/143-add-purl2url-cocoapods-repo-url-support
Add repo URL support and testing for cocoapods
2 parents f98abf0 + 7ebe681 commit 04a706a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/packageurl/contrib/purl2url.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ def build_golang_repo_url(purl):
304304
return f"https://pkg.go.dev/{namespace}/{name}"
305305

306306

307+
@repo_router.route("pkg:cocoapods/.*")
308+
def build_cocoapods_repo_url(purl):
309+
"""
310+
Return a CocoaPods repo URL from the `purl` string.
311+
"""
312+
purl_data = PackageURL.from_string(purl)
313+
name = purl_data.name
314+
return name and f"https://cocoapods.org/pods/{name}"
315+
316+
307317
# Download URLs:
308318

309319

tests/contrib/test_purl2url.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def test_purl2url_get_repo_url():
6565
"pkg:golang/xorm.io/xorm": "https://pkg.go.dev/xorm.io/xorm",
6666
"pkg:golang/xorm.io/xorm@v0.8.2": "https://pkg.go.dev/xorm.io/xorm@v0.8.2",
6767
"pkg:golang/gopkg.in/ldap.v3@v3.1.0": "https://pkg.go.dev/gopkg.in/ldap.v3@v3.1.0",
68+
"pkg:cocoapods/AFNetworking@4.0.1": "https://cocoapods.org/pods/AFNetworking",
69+
"pkg:cocoapods/MapsIndoors@3.24.0": "https://cocoapods.org/pods/MapsIndoors",
6870
}
6971

7072
for purl, url in purls_url.items():
@@ -143,6 +145,7 @@ def test_purl2url_get_inferred_urls():
143145
"https://gitlab.com/tg1999/firebase/-/archive/1a122122/firebase-1a122122.tar.gz",
144146
],
145147
"pkg:pypi/sortedcontainers@2.4.0": ["https://pypi.org/project/sortedcontainers/2.4.0/"],
148+
"pkg:cocoapods/AFNetworking@4.0.1": ["https://cocoapods.org/pods/AFNetworking"],
146149
"pkg:composer/psr/log@1.1.3": ["https://packagist.org/packages/psr/log#1.1.3"],
147150
"pkg:rubygems/package-name": ["https://rubygems.org/gems/package-name"],
148151
"pkg:bitbucket/birkenfeld": [],

0 commit comments

Comments
 (0)