Skip to content

Commit

Permalink
Improve support for SourceForge URLs in url2purl #139
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Jan 8, 2024
1 parent ca1e7e3 commit f7f41b8
Show file tree
Hide file tree
Showing 4 changed files with 20 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.13.4 (2024-01-08)
-------------------

- Improve support for SourceForge URLs in `url2purl`.
https://github.com/package-url/packageurl-python/issues/139

0.13.3 (2024-01-04)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = packageurl-python
version = 0.13.3
version = 0.13.4
license = MIT
description = A purl aka. Package URL parser and builder
long_description = file:README.rst
Expand Down
12 changes: 12 additions & 0 deletions src/packageurl/contrib/url2purl.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ def build_pypi_purl(uri):
register_pattern("sourceforge", sourceforge_download_pattern)


# https://sourceforge.net/projects/spacesniffer/files/spacesniffer_1_3_0_2.zip/download
sourceforge_download_pattern_bis = (
r"^https?://.*sourceforge.net/projects/"
r"(?P<name>.+)/"
r"files/"
r"(?i:(?P=name))_*(?P<version>[0-9_]+).*"
r"(/download)$" # ending with "/download"
)

register_pattern("sourceforge", sourceforge_download_pattern_bis)


@purl_router.route("https?://.*sourceforge.net/project/.*")
def build_sourceforge_purl(uri):
# We use a more general route pattern instead of using `sourceforge_pattern`
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 @@ -175,6 +175,7 @@
"https://sourceforge.net/projects/turbovnc/files/3.1/turbovnc-3.1.tar.gz/download": "pkg:sourceforge/[email protected]",
"https://sourceforge.net/projects/ventoy/files/v1.0.96/Ventoy%201.0.96%20release%20source%20code.tar.gz/download": "pkg:sourceforge/[email protected]",
"https://sourceforge.net/projects/geoserver/files/GeoServer/2.23.4/geoserver-2.23.4-war.zip/download": "pkg:sourceforge/[email protected]",
"https://sourceforge.net/projects/spacesniffer/files/spacesniffer_1_3_0_2.zip/download": "pkg:sourceforge/spacesniffer@1_3_0_2",
"https://crates.io/api/v1/crates/rand/0.7.2/download": "pkg:cargo/[email protected]",
"https://crates.io/api/v1/crates/clap/2.33.0/download": "pkg:cargo/[email protected]",
"https://crates.io/api/v1/crates/structopt/0.3.11/download": "pkg:cargo/[email protected]",
Expand Down

0 comments on commit f7f41b8

Please sign in to comment.