Skip to content

Commit

Permalink
Add support for GitLab "/archive/" URLs in url2purl #133
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Dec 8, 2023
1 parent 0d33368 commit 81a1665
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

0.11.3 (2023-12-08)
--------------------

- Add support for GitLab "/archive/" URLs in `url2purl`.
https://github.com/package-url/packageurl-python/issues/133

0.11.2 (2022-07-25)
--------------------

Expand Down
13 changes: 12 additions & 1 deletion src/packageurl/contrib/url2purl.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def build_bitbucket_purl(url):
)


@purl_router.route("https?://gitlab\\.com/.*")
@purl_router.route("https?://gitlab\\.com/(?!.*/archive/).*")
def build_gitlab_purl(url):
"""
Return a PackageURL object from Gitlab `url`.
Expand Down Expand Up @@ -602,6 +602,17 @@ def build_gitlab_purl(url):
)


# https://gitlab.com/hoppr/hoppr/-/archive/v1.11.1-dev.2/hoppr-v1.11.1-dev.2.tar.gz
gitlab_archive_pattern = (
r"^https?://gitlab.com/"
r"(?P<namespace>.+)/(?P<name>.+)/-/archive/(?P<version>.+)/"
r"(?P=name)-(?P=version).*"
r"[^/]$"
)

register_pattern("gitlab", gitlab_archive_pattern)


# https://hackage.haskell.org/package/cli-extras-0.2.0.0/cli-extras-0.2.0.0.tar.gz
hackage_download_pattern = (
r"^https?://hackage.haskell.org/package/"
Expand Down
1 change: 1 addition & 0 deletions tests/contrib/data/url2purl.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
"https://gitlab.com/TG1999/firebase/-/tree/master": "pkg:gitlab/tg1999/firebase@master",
"https://gitlab.com/tg1999/Firebase/-/tree/master": "pkg:gitlab/tg1999/firebase@master",
"https://gitlab.com/TG1999/FIREBASE": "pkg:gitlab/tg1999/firebase",
"https://gitlab.com/hoppr/hoppr/-/archive/v1.11.1-dev.2/hoppr-v1.11.1-dev.2.tar.gz": "pkg:gitlab/hoppr/[email protected]",
"https://hackage.haskell.org/package/a50-0.5/a50-0.5.tar.gz": "pkg:hackage/[email protected]",
"https://hackage.haskell.org/package/AC-HalfInteger-1.2.1/AC-HalfInteger-1.2.1.tar.gz": "pkg:hackage/[email protected]",
"https://hackage.haskell.org/package/3d-graphics-examples-0.0.0.2/3d-graphics-examples-0.0.0.2.tar.gz": "pkg:hackage/[email protected]",
Expand Down

0 comments on commit 81a1665

Please sign in to comment.