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 <tdruez@nexb.com>
  • Loading branch information
tdruez committed Jan 4, 2024
1 parent a6a3211 commit 944171e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
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.2 (2024-01-04)
-------------------

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

0.13.1 (2023-12-11)
-------------------

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.1
version = 0.13.2
license = MIT
description = A purl aka. Package URL parser and builder
long_description = file:README.rst
Expand Down
6 changes: 4 additions & 2 deletions src/packageurl/contrib/url2purl.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def build_pypi_purl(uri):
register_pattern("nuget", nuget_api_pattern)


@purl_router.route("https?://.*sourceforge.net/project/.*")
@purl_router.route("https?://.*sourceforge.net/projects?/.*")
def build_sourceforge_purl(uri):
# We use a more general route pattern instead of using `sourceforge_pattern`
# below by itself because we want to capture all sourceforge download URLs,
Expand All @@ -353,9 +353,11 @@ def build_sourceforge_purl(uri):
# URL that we can't handle.

# http://master.dl.sourceforge.net/project/libpng/zlib/1.2.3/zlib-1.2.3.tar.bz2
# https://sourceforge.net/projects/scribus/files/scribus/1.6.0/scribus-1.6.0.tar.gz/download
sourceforge_pattern = (
r"^https?://.*sourceforge.net/project/"
r"^https?://.*sourceforge.net/projects?/"
r"(?P<namespace>([^/]+))/" # do not allow more "/" segments
r"(files/)?" # optional segment for "*/download" type URLs
r"(?P<name>.+)/"
r"(?P<version>[0-9\.]+)/" # version restricted to digits and dots
r"(?P=name)-(?P=version).*" # {name}-{version} repeated in the filename
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 @@ -171,6 +171,7 @@
"http://master.dl.sourceforge.net/project/urlchecker/lu/ng/urlchecker/urlchecker/1.7/urlchecker-1.7-javadoc.jar": "pkg:sourceforge/urlchecker?download_url=http://master.dl.sourceforge.net/project/urlchecker/lu/ng/urlchecker/urlchecker/1.7/urlchecker-1.7-javadoc.jar",
"http://master.dl.sourceforge.net/project/zclasspath/maven2/org/zclasspath/zclasspath/1.5/zclasspath-1.5.jar": "pkg:sourceforge/zclasspath?download_url=http://master.dl.sourceforge.net/project/zclasspath/maven2/org/zclasspath/zclasspath/1.5/zclasspath-1.5.jar",
"http://master.dl.sourceforge.net/project/googleimagedown/project/v1.1/GoogleImageDownloader-v1.1-src.tar.bz2": "pkg:sourceforge/googleimagedown?download_url=http://master.dl.sourceforge.net/project/googleimagedown/project/v1.1/GoogleImageDownloader-v1.1-src.tar.bz2",
"https://sourceforge.net/projects/scribus/files/scribus/1.6.0/scribus-1.6.0.tar.gz/download": "pkg:sourceforge/scribus/scribus@1.6.0",
"https://crates.io/api/v1/crates/rand/0.7.2/download": "pkg:cargo/rand@0.7.2",
"https://crates.io/api/v1/crates/clap/2.33.0/download": "pkg:cargo/clap@2.33.0",
"https://crates.io/api/v1/crates/structopt/0.3.11/download": "pkg:cargo/structopt@0.3.11",
Expand Down

0 comments on commit 944171e

Please sign in to comment.