-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordered url params #4262
Comments
The param names assigned to the path are entirely under your control, so I fail to see any scenario in which you wouldn't already know the order. E.g., if you have the path Perhaps I'm failing to understand your use case. |
This is an edge case. I land on page with the following URL: I do have access to From here I want to display in my component something that looks like "Anything > Romain > Nintendo" (and make each segment a clickable link, but that's easy). I want a dynamic behaviour, so i derive from the SK const pathname = $page.url; // /anything/1/1
const {id, clientId} = $page.params;
const name = await getUserName(id); // Romain
const clientName = await getClientName(clientId); // Nintendo
const segments = pathname.substring(1).split('/') // ['anything', '1', '1'] Now i want to replace both How do I know it's |
Do you have any URLs with the format |
That could be a solution, but the idea is to have a derived store with as little hard-coding as possible, given the fact that my app already has quite the number of slugged route configurations. I currently rely on the idea (or hope) that all my ids are unique, which kind of solves the issue, but that feels odd. Again, I know this is an edge case. |
Have you tried doing |
Correct, the keys will enumerate left-to-right. In any case, #4345 will make the |
Describe the problem
It's currently impossible to have information about the order of url
params
.Say i have the following path:
/anything/${id}/${otherId}
, and i want to display in a breadcrumbs component content related to eachid
andotherId
(for instance a name, fetched from a distant api).$page.params
gives{id, otherId}
, which can be used to get a reverse mapping between the slug values in the path and the name of each param, helpful to know what to do with each value (basically fetch data).But what if
id
andotherId
actually are the same value, 1 for instance ? In this case, the reversing mapping would be broken, since we'd get{1: 'otherId'}
, and lose the info aboutid
.Describe the proposed solution
Maybe make an
orderedParams
available in InputProps andpage
store.It would provide
[{slug: 'id', value: 1}, {slug: 'otherId', value: 1}]
, or even just['id', 'otherId']
.Alternatives considered
Hope all the ids are unique.
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: