Skip to content

Fix URL encoding of route values in routeless test helpers - #1171

Open
Benziza wants to merge 1 commit into
FastEndpoints:mainfrom
Benziza:fix/encode-routeless-route-values
Open

Fix URL encoding of route values in routeless test helpers#1171
Benziza wants to merge 1 commit into
FastEndpoints:mainfrom
Benziza:fix/encode-routeless-route-values

Conversation

@Benziza

@Benziza Benziza commented Sep 1, 2026

Copy link
Copy Markdown

Summary

URL-encode hydrated route parameter values generated by GetTestUrlFor().

Route values containing reserved URI characters such as #, ?, or spaces are currently inserted directly into the generated URL. This can truncate or alter the request before it reaches the endpoint.

Reproduction

Given the following route:

Get("/items/{name}");

And this request value:

Name = "part#1?x y";

GetTestUrlFor() currently generates:

items/part#1?x y

The actual request path becomes:

/items/part

Fix

Encode hydrated route parameter values with Uri.EscapeDataString() while preserving unresolved route placeholders.

Catch-all route handling is intentionally outside the scope of this change.

Tests

  • HttpClientExtensionsTests: 12/12 passed
  • Unit.FastEndpoints: 346/346 passed
  • Full solution build: 0 warnings and 0 errors

@Benziza

Benziza commented Sep 1, 2026

Copy link
Copy Markdown
Author

Companion documentation PR: FastEndpoints/Documentation#40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant