Skip to content

Normalize versions using the canonical package type - #247

Open
khushalx wants to merge 1 commit into
package-url:mainfrom
khushalx:codex/normalized-type-version
Open

khushalx wants to merge 1 commit into
package-url:mainfrom
khushalx:codex/normalized-type-version

Conversation

@khushalx

@khushalx khushalx commented Dec 1, 2026

Copy link
Copy Markdown

Fixes #246.

normalize() normalizes the package type before handling the name and namespace, but passes the original type to version normalization. As a result, an OCI or Hugging Face URL created with an uppercase or byte-valued type can change its version and compare unequal after a string round trip.

Pass the normalized type to normalize_version() too. Tests cover construction, round trips, all three encoding modes, and a Maven version whose case must be preserved. Includes a changelog entry.

Validation on Python 3.12.16: 17 regression cases fail before the fix; all 1004 tests and doctests pass afterwards. Isort, Black, mypy (1.20.2, supporting the configured Python 3.9 target), git diff --check, and sdist/wheel builds pass.

AI assistance: OpenAI Codex helped investigate, implement, and test this change.

Keep OCI and Hugging Face versions normalized when callers supply mixed-case or byte-valued types, so PackageURL round trips preserve equality.

Fixes package-url#246

Signed-off-by: khushalx <khushaldangar29@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

normalize() passes unnormalized type to normalize_version(), leaving 'OCI' and 'HuggingFace' versions unlowercased

1 participant