Skip to content

server: tolerate repeated and trailing slashes in request paths - #119

Open
manlikeHB wants to merge 1 commit into
lightningdevkit:mainfrom
manlikeHB:118-tolerate-repeated-and-trailing-slashes
Open

manlikeHB wants to merge 1 commit into
lightningdevkit:mainfrom
manlikeHB:118-tolerate-repeated-and-trailing-slashes

Conversation

@manlikeHB

Copy link
Copy Markdown

Clients concatenate the base URL with the endpoint name, so a base URL ending in / requests /vss//getObject. Stripping /vss leaves //getObject, matching no endpoint and returning 400, which downstream in ldk-node looks identical to a misconfigured server (lightningdevkit/ldk-node/issues/672).

Normalize the path once, before the /metrics check: collapse runs of / and drop a trailing /. Safe because the router has four fixed literals and no path parameters, so no two routes can collide.

Behaviour change: /metrics tolerates the same variants, so //metrics and /metrics/ now return 200 instead of 400.

Fixes #118.

Clients build endpoint URLs by concatenating the base URL with the endpoint
name, so a base URL ending in '/' asks for '/vss//getObject'. That matched no
endpoint and returned 400, surfacing downstream in ldk-node as a generic
store read failure.

Collapse runs of '/' and drop a trailing '/' before routing. /metrics is
dispatched before the authorizer runs, so it becomes tolerant of the same
variants too: '//metrics' and '/metrics/' now return 200 instead of 400.
@ldk-reviews-bot

ldk-reviews-bot commented Nov 26, 2026 •

Copy link
Copy Markdown

I've assigned @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

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.

Tolerate repeated and trailing slashes when routing request paths

2 participants