Skip to content

fix(client): preserve trailing slash on bare-root path pattern#441

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/101-trailing-slash
May 11, 2026
Merged

fix(client): preserve trailing slash on bare-root path pattern#441
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/101-trailing-slash

Conversation

@fredbi
Copy link
Copy Markdown
Member

@fredbi fredbi commented May 11, 2026

The reinstateSlash logic in resolveURLPath (introduced in 6cdcb95 to fix #289) deliberately excluded pathPattern == "/" to avoid producing "//" when basePath was empty or "/". That left one combination inconsistent with every other trailing-slash case: basePath=/myservice with pathPattern=/ produced /myservice instead of /myservice/.

Replace the pattern-shape carve-out with a HasSuffix check on the already-built urlPath, which is idempotent and keeps the double-slash cases unchanged.

Closes #101

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

The reinstateSlash logic in resolveURLPath (introduced in 6cdcb95 to
fix go-openapi#289) deliberately excluded pathPattern == "/" to avoid producing
"//" when basePath was empty or "/". That left one combination
inconsistent with every other trailing-slash case: basePath=/myservice
with pathPattern=/ produced /myservice instead of /myservice/.

Replace the pattern-shape carve-out with a HasSuffix check on the
already-built urlPath, which is idempotent and keeps the double-slash
cases unchanged.

Closes go-openapi#101

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
@fredbi fredbi merged commit 5286530 into go-openapi:master May 11, 2026
19 checks passed
@fredbi fredbi deleted the fix/101-trailing-slash branch May 11, 2026 22:12
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.79%. Comparing base (0d73e8c) to head (d89ebef).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #441      +/-   ##
==========================================
+ Coverage   84.72%   84.79%   +0.07%     
==========================================
  Files          58       58              
  Lines        3809     3808       -1     
==========================================
+ Hits         3227     3229       +2     
+ Misses        442      440       -2     
+ Partials      140      139       -1     

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

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.

Trailing slash removed from root requests

1 participant