Skip to content

fix: handle literal colons in URL paths for denco router#422

Merged
fredbi merged 2 commits intogo-openapi:masterfrom
KuaaMU:fix/literal-colons-in-paths
May 1, 2026
Merged

fix: handle literal colons in URL paths for denco router#422
fredbi merged 2 commits intogo-openapi:masterfrom
KuaaMU:fix/literal-colons-in-paths

Conversation

@KuaaMU
Copy link
Copy Markdown
Contributor

@KuaaMU KuaaMU commented May 1, 2026

Summary

Handle literal colons in URL path segments for the denco router.

Motivation

Fixes #352. The denco router uses : as a parameter delimiter, but : is a valid character in URL path segments per RFC 3986. Routes like /allow/{serverName}/tokenlist:add were being misinterpreted — the : in tokenlist:add was treated as a parameter prefix.

Changes

  • Added escapeLiteralColons() function that replaces literal : with %3A in path segments that aren't parameter delimiters
  • Applied in AddRoute(), Lookup(), and OtherMethods() — the three places where paths interact with the denco router
  • Added tests: unit test for the escape function, integration tests with denco router for static paths, parametric paths, and mixed cases

Verification

go test ./middleware/... -v -run "Colon|Literal"
go test work ./...

All tests pass across all 14 packages.

KuaaMU added 2 commits May 1, 2026 17:03
The denco router uses ':' as a parameter delimiter, but ':' is a valid
character in URL path segments per RFC 3986. Routes like
'/allow/{serverName}/tokenlist:add' were being misinterpreted.

Added escapeLiteralColons() to encode literal ':' as '%3A' before the
router's parameter detection runs. Applied in AddRoute(), Lookup(), and
OtherMethods().

Fixes go-openapi#352

Signed-off-by: KuaaMU <138859253+KuaaMU@users.noreply.github.com>
Signed-off-by: KuaaMU <138859253+KuaaMU@users.noreply.github.com>
Copy link
Copy Markdown
Member

@fredbi fredbi left a comment

Choose a reason for hiding this comment

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

Thanks for this addition. Looks good to me.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.69%. Comparing base (ab827de) to head (5a98e19).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #422      +/-   ##
==========================================
+ Coverage   81.68%   81.69%   +0.01%     
==========================================
  Files          50       50              
  Lines        3379     3381       +2     
==========================================
+ Hits         2760     2762       +2     
  Misses        507      507              
  Partials      112      112              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fredbi fredbi merged commit 8fe7420 into go-openapi:master May 1, 2026
21 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.

Router does not correctly handle route with ":" in it

2 participants