Skip to content
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

Properly serializing non-primitive / array query parameters #14598

Closed
buschtoens opened this issue Nov 9, 2016 · 4 comments
Closed

Properly serializing non-primitive / array query parameters #14598

buschtoens opened this issue Nov 9, 2016 · 4 comments

Comments

@buschtoens
Copy link
Contributor

buschtoens commented Nov 9, 2016

Query parameters seems to be getting a lot of attention lately, so I wanted to chime in with a feature request.

Currently non-primitive query parameter values are just passed through encodeURIComponent(JSON.stringify(value)), which results in rather ugly URLs.

This example controller pushes a 'd' onto the original array, triggering a QP change.

export default Ember.Controller.extend({
  queryParams: ['array'],
  array: ['a' ,'b', 'c'],
  
  init() {
    this._super(...arguments);
    
    Ember.run.schedule('afterRender', null, () => {
      this.get('array').pushObject('d');
    });
  }
});

The URL I would expect is:

/?array[]=a&array[]=b&array[]=c&array[]=d

However the URL I get is:

/?array=%5B%22a%22%2C%22b%22%2C%22c%22%2C%22d%22%5D

Here's a Twiddle.

@rwjblue
Copy link
Member

rwjblue commented Nov 9, 2016

/cc @nathanhammond

@rwjblue
Copy link
Member

rwjblue commented Nov 10, 2016

I believe this is a duplicate of #14174, can you review and confirm?

@nathanhammond
Copy link
Member

I do consider this to be a duplicate of #14174. @buschtoens I'm working on this over here: https://github.com/nathanhammond/query-string-spec

@buschtoens
Copy link
Contributor Author

Awesome! I'll keep an eye on your repo. Thaks a lot. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants