Skip to content

Preserve case in Go module PURLs - #54

Merged
andrew merged 3 commits into
git-pkgs:mainfrom
dannyward630:fix/53-preserve-golang-case
Oct 28, 2026
Merged

andrew merged 3 commits into
git-pkgs:mainfrom
dannyward630:fix/53-preserve-golang-case

Conversation

@dannyward630

Copy link
Copy Markdown
Contributor

Summary

Go module paths are case-sensitive, but packageurl-go lowercases the namespace and name during normalization. Restore the original decoded path components for golang PURLs so parsing and all construction helpers preserve module identity.

Regression coverage exercises literal and percent-encoded uppercase paths through Parse, New, BuildPURLString, MakePURL, and MakePURLString.

Fixes #53

Verification

  • go build ./... — passed (Go 1.27.3, windows/amd64)
  • go test ./... -count=1 — passed
  • go test -race ./... -count=1 — passed
  • go vet ./... — passed
  • golangci-lint run --new-from-rev=origin/main — passed, 0 issues
  • Full local golangci-lint run reports gofmt findings in unchanged comparison.go, defaults.go, and doc.go due to their CRLF checkout; LF-normalized copies are gofmt-clean. No unrelated files were changed.
  • The Go 1.26 CI lane was not run locally.

AI assistance: Codex (GPT-6) assisted with implementation and regression tests.

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up — the approach is right and the parse recovery matches packageurl-go's own split for every input FromString accepts as golang. Two small cleanups before merge:

  • purl.go:92 — the strings.Trim around strings.Join(decoded, "/") is dead: empty segments are already filtered out of decoded, so the join can never produce a leading or trailing /. Assign namespace = strings.Join(decoded, "/") directly.
  • purl.go:121-124 — New's godoc lost the invariant it was documenting ("so New and Parse produce the same string for equivalent inputs") in favour of a golang-specific sentence that preserveGolangCase's own comment already covers. Please restore the original four lines; "the same per-type rules Parse applies" now covers golang too, since Parse preserves case.

@dannyward630

Copy link
Copy Markdown
Contributor Author

Addressed both cleanups in a40d761: originalGolangPath now assigns strings.Join(decoded, "/") directly, and New’s original normalization contract is restored. go test ./... -count=1 passes with Go 1.27.3 after initializing the repository’s testdata/purl-spec submodule. Please re-review.

@dannyward630
dannyward630 requested a review from andrew October 28, 2026 12:31
@andrew
andrew merged commit 39d42b7 into git-pkgs:main Oct 28, 2026
3 checks passed
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.

Parse lowercases golang module paths

2 participants