Skip to content

Commit 944171e

Browse files
committed
Improve support for SourceForge URLs in url2purl #139
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent a6a3211 commit 944171e

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
0.13.2 (2024-01-04)
5+
-------------------
6+
7+
- Improve support for SourceForge URLs in `url2purl`.
8+
https://github.com/package-url/packageurl-python/issues/139
9+
410
0.13.1 (2023-12-11)
511
-------------------
612

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = packageurl-python
3-
version = 0.13.1
3+
version = 0.13.2
44
license = MIT
55
description = A purl aka. Package URL parser and builder
66
long_description = file:README.rst

src/packageurl/contrib/url2purl.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def build_pypi_purl(uri):
344344
register_pattern("nuget", nuget_api_pattern)
345345

346346

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

355355
# http://master.dl.sourceforge.net/project/libpng/zlib/1.2.3/zlib-1.2.3.tar.bz2
356+
# https://sourceforge.net/projects/scribus/files/scribus/1.6.0/scribus-1.6.0.tar.gz/download
356357
sourceforge_pattern = (
357-
r"^https?://.*sourceforge.net/project/"
358+
r"^https?://.*sourceforge.net/projects?/"
358359
r"(?P<namespace>([^/]+))/" # do not allow more "/" segments
360+
r"(files/)?" # optional segment for "*/download" type URLs
359361
r"(?P<name>.+)/"
360362
r"(?P<version>[0-9\.]+)/" # version restricted to digits and dots
361363
r"(?P=name)-(?P=version).*" # {name}-{version} repeated in the filename

tests/contrib/data/url2purl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
"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",
172172
"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",
173173
"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",
174+
"https://sourceforge.net/projects/scribus/files/scribus/1.6.0/scribus-1.6.0.tar.gz/download": "pkg:sourceforge/scribus/scribus@1.6.0",
174175
"https://crates.io/api/v1/crates/rand/0.7.2/download": "pkg:cargo/rand@0.7.2",
175176
"https://crates.io/api/v1/crates/clap/2.33.0/download": "pkg:cargo/clap@2.33.0",
176177
"https://crates.io/api/v1/crates/structopt/0.3.11/download": "pkg:cargo/structopt@0.3.11",

0 commit comments

Comments
 (0)