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

[query-params-new] don't serialize null or undefined to url #4571

Closed
wants to merge 1 commit into from

Conversation

raytiley
Copy link
Contributor

null and undefined are no longer serialized into the url. This behavior might not be right though as its now ambiguous as to weather you want the default value for a query param, or you want the value to be null There is more of a discussion in #4570.

@raytiley raytiley changed the title [query-params-new] failing tests for #4570 [query-params-new] don't serialize null or undefined to url Mar 24, 2014
@@ -1636,7 +1636,9 @@ if (Ember.FEATURES.isEnabled("query-params-new")) {
// urlKey isn't used here, but anyone overriding
// can use it to provide serialization specific
// to a certain query param.
if (defaultValueType === 'array') {
if (value === null || value === undefined) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should false be handled the same way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be. The '' + value will coerce the boolean value into a string which is what we want. We want boolean values to be explicit in the url ?foo=false or ?foo=true

@wagenet wagenet added the bug label Apr 2, 2014
@camthompson
Copy link

I was working through the same issue earlier today and came to a similar conclusion. This is also relevant to #4493.

@rwjblue
Copy link
Member

rwjblue commented Apr 25, 2014

@machty - Thoughts here?

@tonywok
Copy link

tonywok commented May 14, 2014

We've ran into the same issue and agreed with the changeset - impartial to whether undefined should get swallowed into null. I think it would work as typeOf would handle it fine.

Our example is doing pagination and search - using refreshModel. I wouldn't even mind if the route's model hook received a real null value. We can filter those out before we hit the server as opposed to being out of luck with the string "undefined" or "null" - nothing is (or should) be stopping a user from typing that as a search query.

Ironic as I typed "null" in Github to find this PR :P

@ppcano
Copy link
Contributor

ppcano commented May 26, 2014

This fix works for me.

@machty
Copy link
Contributor

machty commented Jun 2, 2014

I think this is out of date but will reopen if someone can demonstrate the issue in a JSBin that uses the following ember.js: http://s3.amazonaws.com/machty/to_s3_uploads/ember-9fbe6c2a-c124-5c2e-0414-f5ed36c2a1a2.js

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

Successfully merging this pull request may close these issues.

None yet

9 participants