Skip to content

feat: add Pathf for segment-escaped request paths#3

Merged
AcidSailor merged 1 commit into
mainfrom
feat/pathf-segment-escaping
Jul 6, 2026
Merged

feat: add Pathf for segment-escaped request paths#3
AcidSailor merged 1 commit into
mainfrom
feat/pathf-segment-escaping

Conversation

@AcidSailor

Copy link
Copy Markdown
Owner

Summary

Adds Pathf, a helper that builds a request path by percent-escaping each interpolated argument as a single path segment (via url.PathEscape). It is the path-side counterpart to Values on the query side.

Callers pass a format like /v1/accounts/%s/orders/%s with raw parameter values; a value containing /, ?, #, or a space is escaped rather than corrupting the URL (injecting a segment, starting a query string, etc.).

  • Every arg is interpolated with %s; use fmt.Sprintf directly for other verbs.
  • An empty arg yields an empty segment — Pathf validates escaping, not presence.

Test plan

  • task test — new table tests in request_test.go cover escaping of /, ?, #, spaces, and multi-arg paths.

🤖 Generated with Claude Code

Pathf builds a request path by percent-escaping each interpolated argument
as a single path segment (via url.PathEscape), the path-side counterpart to
Values on the query side. Callers pass a format like
"/v1/accounts/%s/orders" with raw parameter values; a value containing '/',
'?', '#', or a space is escaped rather than corrupting the URL.
@AcidSailor AcidSailor merged commit 53aa752 into main Jul 6, 2026
2 checks passed
@AcidSailor AcidSailor deleted the feat/pathf-segment-escaping branch July 6, 2026 17:46
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.

1 participant