pateketrueke / yrv

Your routing vibes! (for Svelte)
https://svelte.dev/repl/0f07c6134b16432591a9a3a0095a80de
161 stars 9 forks source link

Optional params #41

Open Daarien opened 4 years ago

Daarien commented 4 years ago

"abstract-nested-router" docs say (of params): "By default all segments are optional, e.g. /a/:b/:c matches with /a, /a/x and /a/x/y so you can say :b and :c are optional parameters."

For "yrv" it is not so. If i need a page with optional params, i have to declare three routes, one for each case:

<Route path="/page/:x/:y">Page</Route>
<Route path="/page/:x">Page</Route>
<Route path="/page">Page</Route>

I need the same component with params based on current path.

Could it be made as in "abstract-nested-router"?

Daarien commented 4 years ago

When i experiment with "/page/:x?/:y?" sometimes it works, but a few moves later i get clean white screen.

pateketrueke commented 4 years ago

Could it be made as in "abstract-nested-router"?

You're right, that functionality was lost, thanks for your feedback!

Daarien commented 4 years ago

One more unpleasant thing. When navigating to page from outside, first level optional param path like "/page/(:param)" works, but when start navigating from inside this page, optional param stop working.

Example https://svelte.dev/repl/3678130b9358496eabf8c84aabf7f2c3?version=3.20.1