Skip to content

Commit 56cc3ee

Browse files
committed
Fixed spaces in purl to download url
Signed-off-by: Omkar Phansopkar <[email protected]>
1 parent e8486c2 commit 56cc3ee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/packageurl/contrib/purl2url.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def get_repo_download_url_by_package_type(
4040
raise ValueError("Only zip and tar.gz extensions are supported")
4141

4242
download_url_by_type = {
43-
"github": f"https://github.com/{namespace}/{name}/archive/{version}.{archive_extension}",
44-
"bitbucket": f"https://bitbucket.org/{namespace}/{name}/get/{version}.{archive_extension}",
45-
"gitlab": f"https://gitlab.com/{namespace}/{name}/-/archive/{version}/{name}-{version}.{archive_extension}",
43+
"github": f"https://github.com/{namespace}/{name}/archive/{version}.{archive_extension}".replace(" ", "+"),
44+
"bitbucket": f"https://bitbucket.org/{namespace}/{name}/get/{version}.{archive_extension}".replace(" ", "+"),
45+
"gitlab": f"https://gitlab.com/{namespace}/{name}/-/archive/{version}/{name}-{version}.{archive_extension}".replace(" ", "+"),
4646
}
4747
return download_url_by_type.get(type)
4848

tests/contrib/test_purl2url.py

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def test_purl2url_get_download_url():
100100
"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",
101101
"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",
102102
"pkg:pypi/[email protected]?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",
103+
"pkg:github/facebook/[email protected]%20f4e9df48": "https://github.com/facebook/sapling/archive/0.2.20240718-145624+f4e9df48.tar.gz",
103104
# Not-supported
104105
"pkg:github/tg1999/fetchcode": None,
105106
"pkg:cargo/abc": None,

0 commit comments

Comments
 (0)