Skip to content

Handle Swift package registry identities without fabricating source PURLs #28

Description

@andrew

Trying to construct PURLs for Swift Package Registry dependencies through MakePURL and BuildPURLString.

Swift registry identifiers use scope.name. For example, the native identifier apple.swift-argument-parser appears in registry HTTP paths as apple/swift-argument-parser.

With v0.1.16, MakePURL has no Swift registry-specific mapping. A caller that splits the HTTP path into namespace and name produces:

pkg:swift/apple/swift-argument-parser@1.8.2

This looks valid but has the wrong meaning. The Swift PURL definition requires the namespace to contain the source host and owner, and the name to contain the repository name. A registry identifier does not necessarily expose that source information.

Steps to reproduce:

  1. Receive the Swift registry identity apple.swift-argument-parser.
  2. Represent its HTTP path as apple/swift-argument-parser.
  3. Construct a Swift PURL from those two components.
  4. Observe that apple is treated as a source namespace even though it is only the registry scope.

The proxy currently needs this for git-pkgs/proxy#259. The shared package should expose a way to distinguish source coordinates from registry identities. Registry identities should not produce source-based pkg:swift values unless their source repository has been resolved. Tests should cover both apple.swift-argument-parser and a source coordinate such as github.com/apple/swift-argument-parser.

The missing standard representation is already tracked in package-url/purl-spec#929. Until that is resolved, this package should return an explicit unsupported result or use a representation that does not claim the registry scope is a source namespace.

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