samedi 29 août 2020

How to maintain unknown/wildcard queryParams through a transition?

I have a route (route-a) that transitions to another route (route-b) and I am trying to find a way for the destination URL to maintain the all query parameters, even if route-b does not know about them in advance.

For example, if a user visits https://example.com/route-a/?var1=x&var2=y, and the transition to route-b happens like this:

afterModel(model, transition) {
  this.transitionTo('route-b', model, {queryParams: transition.to.queryParams}) // transition route-a to route-b
}

...the ultimate URL will be https://example.com/route-b/without the query params.

Now, I realize the "Ember way" is to define the queryParams on route-b's controller in advance, but in this particular use-case, I do not know the queryParams in advance. Route B consumes any and all query params provided to it, which means they would be impossible to enumerate in advance.

How can I transition to a new route without dropping query parameters that are not specifically enumerated on the destination route's controller?

Is there a way to handle unknown queryParams, or is there the notion of a wildcard for queryParams (similar to *path routes)?




Aucun commentaire:

Enregistrer un commentaire