Skip to content

Commit

Permalink
Add backward compatibility for pkg:rubygems type in purl2url #114
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Dec 8, 2023
1 parent 98d4a58 commit a1d782b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/packageurl/contrib/purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def build_gitlab_repo_url(purl):
return f"https://gitlab.com/{namespace}/{name}"


@repo_router.route("pkg:gem/.*")
@repo_router.route("pkg:(gem|rubygems)/.*")
def build_rubygems_repo_url(purl):
"""
Return a rubygems repo URL from the `purl` string.
Expand Down
9 changes: 6 additions & 3 deletions tests/contrib/test_purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def test_purl2url_get_repo_url():
"pkg:cargo/rand@0.7.2": "https://crates.io/crates/rand/0.7.2",
"pkg:cargo/abc": "https://crates.io/crates/abc",
"pkg:gem/bundler@2.3.23": "https://rubygems.org/gems/bundler/versions/2.3.23",
"pkg:rubygems/package-name": None,
"pkg:rubygems/bundler@2.3.23": "https://rubygems.org/gems/bundler/versions/2.3.23",
"pkg:rubygems/package-name": "https://rubygems.org/gems/package-name",
"pkg:bitbucket/birkenfeld/pygments-main": "https://bitbucket.org/birkenfeld/pygments-main",
"pkg:bitbucket/birkenfeld/pygments-main@244fd47e07d1014f0aed9c": "https://bitbucket.org/birkenfeld/pygments-main",
"pkg:bitbucket/birkenfeld/pygments-main@master#views": "https://bitbucket.org/birkenfeld/pygments-main",
Expand Down Expand Up @@ -128,8 +129,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/sortedcontainers@2.4.0": ["https://pypi.org/project/sortedcontainers/2.4.0/"],
"pkg:rubygems/package-name": [],
"pkg:pypi/sortedcontainers@2.4.0": [
"https://pypi.org/project/sortedcontainers/2.4.0/"
],
"pkg:rubygems/package-name": ["https://rubygems.org/gems/package-name"],
"pkg:bitbucket/birkenfeld": [],
}

Expand Down

0 comments on commit a1d782b

Please sign in to comment.