Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

querystring nested problem #103

Closed
alessioalex opened this Issue · 7 comments

5 participants

@alessioalex

If I send a nested object for the form param:

form: { user: { user:'avsstu', password:'ricardoo' } }

querystring will stringify it like: 'user='

However if the object is not nested it will stringify it properly:

form: { user: user:'avsstu', password:'ricardoo' }

it works ok, returns: 'user=avsstu&password=ricardoo'

I know you don't want dependencies, but I don't consider the 'querystring' module to behave correctly like so. I suggest we use https://github.com/visionmedia/node-querystring for this.

@alessioalex

If you want I can implement and test this myself.

@ericboehs

Yeah I'm having this issue as well. I'd love to see this implemented.

@mikeal
Owner

is there a specification of any kind for "nested querystrings"?

i thought querystrings can only be a flat key/value pair?

@mikeal mikeal closed this
@alessioalex

An example of a possible POST form:

<input id="user_name" name="user[name]" size="30" type="search" />
<input id="user_phone" name="user[phone]" size="30" type="tel" />
<input id="user_homepage" size="30" name="user[homepage]" type="url" />
<input id="user_address" size="30" name="user[address]" type="email" />

Taken from: http://guides.rubyonrails.org/form_helpers.html

If this form would be POST the result would be something like: ?user[homepage]=www&user[address]=... etc.
The regular querystring module for Node wouldn't parse that correctly, but TJ's querystring module would.

@jmonster

+1 disappointed it doesn't work this way ... is this a rails convention rather than a standard? node-express properly parses inputs the same way ruby on rails does, so I was begining to believe this was a best practice node-request would support

@tanertopal

+1 need that too...

@mikeal
Owner

my concern is that this might be a breaking change as it changes the actual posted string. as i understand it, the querystring module in core is suppose to match querystring parsing in the browser, which might be standardized. if it's not, and this is unlikely to break any assumptions, i'm happy to take it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.