Skip to content

fix(listen): join the forwarding URL path and the event path with a single slash - #478

Open
pcbeingused333 wants to merge 1 commit into
hookdeck:mainfrom
pcbeingused333:fix/listen-trailing-slash-forward-url
Open

pcbeingused333 wants to merge 1 commit into
hookdeck:mainfrom
pcbeingused333:fix/listen-trailing-slash-forward-url

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #475.

processAttempt builds the forwarded URL as cfg.URL.Path + webhookEvent.Body.Path, so a forwarding URL whose path ends in / (hookdeck listen http://127.0.0.1:47913/base/ <source>) sends every request to /base//webhook instead of /base/webhook.

The two paths are now joined by joinForwardPath, which drops one trailing / from the forwarding URL's path when the event path starts with /. The event path is otherwise kept as is, since a receiver may route on its own trailing slash (which is why path.Join is not used), and an empty event path still forwards to the forwarding URL's path unchanged.

forward_path_test.go runs one attempt through processAttempt against a local server for six cases: forwarding path with and without a trailing slash, the root, no path, an event path with its own trailing slash, and an empty event path. On master the three cases whose forwarding path ends in / (/base/, / and an event path with its own trailing slash) fail with //; with this change all six pass. go vet ./... passes. go test ./... passes apart from two tests in packages this change does not touch, which fail the same way on master in the container used: TestCheckServerHealth_DefaultPorts/HTTPS_default_port (needs an outbound connection to port 443) and TestLogin_rejectedKeyHeadlessFailsFast in pkg/login. The acceptance tests were not run.

The issue also notes that a query string on the forwarding URL is dropped; that is not changed here, since forwarding it or rejecting it at startup is a behaviour choice.

This change was prepared with Claude Code.

…ingle slash

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

listen: a trailing slash on the forwarding URL produces // in the forwarded path

1 participant