Skip to content

fix: avoid encoding '/' in wildcard route segments#4056

Open
Madoshakalaka wants to merge 1 commit intomasterfrom
fix/router-wildcard-encoding
Open

fix: avoid encoding '/' in wildcard route segments#4056
Madoshakalaka wants to merge 1 commit intomasterfrom
fix/router-wildcard-encoding

Conversation

@Madoshakalaka
Copy link
Member

Closes #3514

Checklist

  • I have reviewed my own code
  • I have added tests

The Routable derive macro applied encode_for_url uniformly to all route
parameters, including wildcard (*path) segments. This caused '/' within
wildcard values to be encoded as '%2F', producing broken URLs like
'/file/docs%2Fguides%2Fgetting-started.md' instead of
'/file/docs/guides/getting-started.md'.

The fix introduces encode_path_for_url which splits on '/', encodes
each segment individually, then rejoins with '/'. The macro now tracks
which fields originate from wildcard patterns and uses the path-aware
encoder for those fields while keeping the existing encoder for named
(:param) segments.

Closes #3514
@github-actions
Copy link

github-actions bot commented Mar 8, 2026

Visit the preview URL for this PR (updated for commit a09ee64):

https://yew-rs-api--pr4056-fix-router-wildcard-vdjb461i.web.app

(expires Sun, 15 Mar 2026 06:52:15 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

github-actions bot commented Mar 8, 2026

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 99.690 99.690 0 0.000%
boids 167.615 167.615 0 0.000%
communication_child_to_parent 93.062 93.062 0 0.000%
communication_grandchild_with_grandparent 104.835 104.835 0 0.000%
communication_grandparent_to_grandchild 101.145 101.145 0 0.000%
communication_parent_to_child 90.464 90.464 0 0.000%
contexts 104.901 104.901 0 0.000%
counter 85.797 85.797 0 0.000%
counter_functional 87.808 87.808 0 0.000%
dyn_create_destroy_apps 89.864 89.864 0 0.000%
file_upload 98.881 98.881 0 0.000%
function_delayed_input 93.910 93.910 0 0.000%
function_memory_game 172.582 172.582 0 0.000%
function_router 405.527 405.527 0 0.000%
function_todomvc 163.920 163.920 0 0.000%
futures 234.689 234.689 0 0.000%
game_of_life 104.357 104.357 0 0.000%
immutable 254.754 254.754 0 0.000%
inner_html 80.328 80.328 0 0.000%
js_callback 108.950 108.950 0 0.000%
keyed_list 179.319 179.319 0 0.000%
mount_point 83.716 83.716 0 0.000%
nested_list 112.420 112.420 0 0.000%
node_refs 91.102 91.102 0 0.000%
password_strength 1728.598 1728.598 0 0.000%
portals 92.598 92.598 0 0.000%
router 376.465 376.465 0 0.000%
suspense 113.166 113.166 0 0.000%
timer 88.203 88.203 0 0.000%
timer_functional 96.949 96.949 0 0.000%
todomvc 141.856 141.856 0 0.000%
two_apps 85.746 85.746 0 0.000%
web_worker_fib 135.675 135.675 0 0.000%
web_worker_prime 186.812 186.812 0 0.000%
webgl 82.724 82.724 0 0.000%

✅ None of the examples has changed their size significantly.

@Madoshakalaka Madoshakalaka added A-yew-router Area: The yew-router crate A-yew-router-macro Area: The yew-router-macro crate and removed A-yew-router Area: The yew-router crate labels Mar 8, 2026
@github-actions
Copy link

github-actions bot commented Mar 8, 2026

Benchmark - SSR

Yew Master

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.777 312.459 311.142 0.477
Hello World 10 478.273 481.796 479.454 1.087
Function Router 10 32815.293 33572.481 33123.632 244.820
Concurrent Task 10 1006.506 1007.752 1007.054 0.403
Many Providers 10 1094.330 1114.858 1104.485 6.383

Pull Request

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.911 317.531 312.035 2.212
Hello World 10 496.138 509.597 499.868 4.456
Function Router 10 33362.141 34571.076 34064.511 442.726
Concurrent Task 10 1006.271 1007.660 1006.864 0.469
Many Providers 10 1079.600 1117.630 1093.732 11.989

@Madoshakalaka Madoshakalaka marked this pull request as ready for review March 8, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-yew-router-macro Area: The yew-router-macro crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Router urlencoding should not encode '/' in *path

1 participant