From 8751b49db7b79686c7dac475412c2a87589280d9 Mon Sep 17 00:00:00 2001 From: Omkar Phansopkar Date: Wed, 6 Nov 2024 00:25:46 +0530 Subject: [PATCH] Fixed spaces in purl to download url Signed-off-by: Omkar Phansopkar --- src/packageurl/contrib/purl2url.py | 2 +- tests/contrib/test_purl2url.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/packageurl/contrib/purl2url.py b/src/packageurl/contrib/purl2url.py index 7e93bd0..92ec182 100644 --- a/src/packageurl/contrib/purl2url.py +++ b/src/packageurl/contrib/purl2url.py @@ -40,7 +40,7 @@ def get_repo_download_url_by_package_type( raise ValueError("Only zip and tar.gz extensions are supported") download_url_by_type = { - "github": f"https://github.com/{namespace}/{name}/archive/{version}.{archive_extension}", + "github": f"https://github.com/{namespace}/{name}/archive/{version}.{archive_extension}".replace(" ", "+"), "bitbucket": f"https://bitbucket.org/{namespace}/{name}/get/{version}.{archive_extension}", "gitlab": f"https://gitlab.com/{namespace}/{name}/-/archive/{version}/{name}-{version}.{archive_extension}", } diff --git a/tests/contrib/test_purl2url.py b/tests/contrib/test_purl2url.py index 6c88c5c..f8add05 100644 --- a/tests/contrib/test_purl2url.py +++ b/tests/contrib/test_purl2url.py @@ -100,6 +100,7 @@ def test_purl2url_get_download_url(): "pkg:bitbucket/robeden/trove?download_url=https://bitbucket.org/robeden/trove/downloads/trove-3.0.3.zip": "https://bitbucket.org/robeden/trove/downloads/trove-3.0.3.zip", "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/zclasspath/maven2/org/zclasspath/zclasspath/1.5/zclasspath-1.5.jar", "pkg:pypi/aboutcode-toolkit@3.4.0rc1?download_url=https://files.pythonhosted.org/packages/87/44/0fa8e9d0cccb8eb86fc1b5170208229dc6d6e9fd6e57ea1fe19cbeea68f5/aboutcode_toolkit-3.4.0rc1-py2.py3-none-any.whl": "https://files.pythonhosted.org/packages/87/44/0fa8e9d0cccb8eb86fc1b5170208229dc6d6e9fd6e57ea1fe19cbeea68f5/aboutcode_toolkit-3.4.0rc1-py2.py3-none-any.whl", + "pkg:github/facebook/sapling@0.2.20240718-145624%20f4e9df48": "https://github.com/facebook/sapling/archive/0.2.20240718-145624+f4e9df48.tar.gz", # Not-supported "pkg:github/tg1999/fetchcode": None, "pkg:cargo/abc": None,