packageurl-python icon indicating copy to clipboard operation
packageurl-python copied to clipboard

Github tags/releases with a `/` in the prefix

Open jloehel opened this issue 11 months ago • 0 comments

Examples:

https://github.com/apache/logging-log4net/archive/refs/tags/rc/2.0.8-RC1.zip
https://github.com/apache/logging-log4net/tree/rel/2.0.8

Parsing those will result in:

❯ pip show packageurl-python
Name: packageurl-python
Version: 0.14.0
Summary: A purl aka. Package URL parser and builder
Home-page: https://github.com/package-url/packageurl-python
Author: the purl authors
Author-email: 
License: MIT
Location: /home/jloehel/python/venv3.9/lib/python3.9/site-packages
Requires: 
Required-by: 
❯ python
Python 3.9.18 (main, Sep 06 2023, 07:49:32) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from packageurl.contrib import url2purl
>>> url2purl.get_purl("https://github.com/apache/logging-log4net/archive/refs/tags/rc/2.0.8-RC1.zip")
PackageURL(type='github', namespace='apache', name='logging-log4net', version='2.0.8-RC1', qualifiers={}, subpath=None)
>>> url2purl.get_purl("https://github.com/apache/logging-log4net/tree/rel/2.0.8")
PackageURL(type='github', namespace='apache', name='logging-log4net', version='rel', qualifiers={}, subpath='2.0.8')
>>>

For the first URI the version is correct but the prefix gets lost. How can I re-construct a working URI from it? The second URI does not work. The version_prefix is the version and the version is the subpath.

Expected result:

pkg:github/apache/[email protected]?version_prefix=rc%2F
pkg:github/apache/[email protected]?version_prefix=rel%2F

Note: https://github.com/apache/logging-log4net/tree/rel/2.0.8 is really tricky and I think not possible to realize just with regular expressions. It would be necessary to know about the existing refs.

jloehel avatar Mar 01 '24 20:03 jloehel