diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 61c4d63..4733872 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) -------------------- diff --git a/src/packageurl/contrib/url2purl.py b/src/packageurl/contrib/url2purl.py index 0f51b2e..aade473 100644 --- a/src/packageurl/contrib/url2purl.py +++ b/src/packageurl/contrib/url2purl.py @@ -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`. @@ -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.+)/(?P.+)/-/archive/(?P.+)/" + 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/" diff --git a/tests/contrib/data/url2purl.json b/tests/contrib/data/url2purl.json index ab92a05..d4c87e2 100644 --- a/tests/contrib/data/url2purl.json +++ b/tests/contrib/data/url2purl.json @@ -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/hoppr@v1.11.1-dev.2", "https://hackage.haskell.org/package/a50-0.5/a50-0.5.tar.gz": "pkg:hackage/a50@0.5", "https://hackage.haskell.org/package/AC-HalfInteger-1.2.1/AC-HalfInteger-1.2.1.tar.gz": "pkg:hackage/AC-HalfInteger@1.2.1", "https://hackage.haskell.org/package/3d-graphics-examples-0.0.0.2/3d-graphics-examples-0.0.0.2.tar.gz": "pkg:hackage/3d-graphics-examples@0.0.0.2",