Skip to content

refactor(server): consolidate duplicate URL parsing into splitRepoPath#468

Merged
dlorenc merged 1 commit into
mainfrom
work/proud-platypus
May 9, 2026
Merged

refactor(server): consolidate duplicate URL parsing into splitRepoPath#468
dlorenc merged 1 commit into
mainfrom
work/proud-platypus

Conversation

@dlorenc

@dlorenc dlorenc commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Two functions (parseRepoPath in handlers.go and repoAndSubPath in middleware.go) were independently implementing the same /-/ URL parsing logic, with comments in both files warning they must stay in sync
  • Introduces splitRepoPath in a new internal/server/url.go as the single source of truth for parsing /repos/.../-/endpoint paths
  • Both wrapper functions now delegate to splitRepoPath, eliminating the duplication and the "keep in sync" comment
  • Adds TestSplitRepoPathConsistency to verify that parseRepoPath and repoAndSubPath produce the same repo name and endpoint for the same input paths

Test plan

  • TestSplitRepoPathConsistency — new test verifying both wrappers agree
  • TestRepoAndSubPath — existing test continues to pass
  • Full ./internal/server/... test suite passes (pre-existing TestDockerSmoke failure is unrelated — requires GCP credentials not available in this environment)
  • go build ./... and go vet ./... clean

🤖 Generated with Claude Code

Both parseRepoPath (handlers.go) and repoAndSubPath (middleware.go) were
independently implementing the same /-/ URL parsing logic, with a comment
in both files warning they must stay in sync.

This change introduces splitRepoPath in a new url.go file as the single
source of truth. Both functions now delegate to it, eliminating the
duplication. Also adds TestSplitRepoPathConsistency to verify the two
wrappers agree on repo name and endpoint for the same input paths.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@dlorenc dlorenc merged commit 1dcbc23 into main May 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant