Skip to content

MakePURL/New skip normalization that Parse applies #21

Description

@andrew

Parse calls packageurl.FromString, which runs Normalize() and applies per-type rules (lowercasing pypi names, composer namespaces, etc). New and MakePURL call packageurl.NewPackageURL directly and skip that step, so the two paths disagree:

purl.Parse("pkg:pypi/Django").String()      // "pkg:pypi/django"
purl.MakePURLString("pypi", "Django", "")   // "pkg:pypi/Django"

This bit git-pkgs/proxy#197: config keys were normalized via Parse but runtime lookup keys came from MakePURLString, so overrides for scoped npm packages and mixed-case pypi packages silently failed to match.

Calling p.Normalize() inside New before returning would make construction and parsing agree. It changes output for existing callers that persist these strings (git-pkgs/proxy#207 tracks the migration on that side), so probably wants a minor version bump and a changelog note.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions