Skip to content

Commit

Permalink
Do the right thing when parsing query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Techwraith committed Mar 7, 2012
1 parent f0ab51b commit 4d275a1
Show file tree
Hide file tree
Showing 17 changed files with 779 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Expand Up @@ -11,3 +11,15 @@ node_modules
tmtags
*.DS_Store
examples/todo_app/log/*
examples/todo_app_mongo/log/access.2012-03-06T23:30:22.log
examples/todo_app_mongo/log/access.2012-03-06T23:32:01.log
examples/todo_app_mongo/log/access.2012-03-07T00:00:22.log
examples/todo_app_mongo/log/access.log
examples/todo_app_mongo/log/stderr.2012-03-06T23:30:22.log
examples/todo_app_mongo/log/stderr.2012-03-06T23:32:01.log
examples/todo_app_mongo/log/stderr.2012-03-07T00:00:22.log
examples/todo_app_mongo/log/stderr.log
examples/todo_app_mongo/log/stdout.2012-03-06T23:30:22.log
examples/todo_app_mongo/log/stdout.2012-03-06T23:32:01.log
examples/todo_app_mongo/log/stdout.2012-03-07T00:00:22.log
examples/todo_app_mongo/log/stdout.log
1 change: 1 addition & 0 deletions deps/qs/.gitignore
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions deps/qs/.gitmodules
@@ -0,0 +1,6 @@
[submodule "support/expresso"]
path = support/expresso
url = git://github.com/visionmedia/expresso.git
[submodule "support/should"]
path = support/should
url = git://github.com/visionmedia/should.js.git
4 changes: 4 additions & 0 deletions deps/qs/.travis.yml
@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.6
- 0.4
73 changes: 73 additions & 0 deletions deps/qs/History.md
@@ -0,0 +1,73 @@

0.4.2 / 2012-02-08
==================

* Fixed: ensure objects are created when appropriate not arrays [aheckmann]

0.4.1 / 2012-01-26
==================

* Fixed stringify()ing numbers. Closes #23

0.4.0 / 2011-11-21
==================

* Allow parsing of an existing object (for `bodyParser()`) [jackyz]
* Replaced expresso with mocha

0.3.2 / 2011-11-08
==================

* Fixed global variable leak

0.3.1 / 2011-08-17
==================

* Added `try/catch` around malformed uri components
* Add test coverage for Array native method bleed-though

0.3.0 / 2011-07-19
==================

* Allow `array[index]` and `object[property]` syntaxes [Aria Stewart]

0.2.0 / 2011-06-29
==================

* Added `qs.stringify()` [Cory Forsyth]

0.1.0 / 2011-04-13
==================

* Added jQuery-ish array support

0.0.7 / 2011-03-13
==================

* Fixed; handle empty string and `== null` in `qs.parse()` [dmit]
allows for convenient `qs.parse(url.parse(str).query)`

0.0.6 / 2011-02-14
==================

* Fixed; support for implicit arrays

0.0.4 / 2011-02-09
==================

* Fixed `+` as a space

0.0.3 / 2011-02-08
==================

* Fixed case when right-hand value contains "]"

0.0.2 / 2011-02-07
==================

* Fixed "=" presence in key

0.0.1 / 2011-02-07
==================

* Initial release
5 changes: 5 additions & 0 deletions deps/qs/Makefile
@@ -0,0 +1,5 @@

test:
@./node_modules/.bin/mocha

.PHONY: test
54 changes: 54 additions & 0 deletions deps/qs/Readme.md
@@ -0,0 +1,54 @@
# node-querystring

query string parser for node supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others.

## Installation

$ npm install qs

## Examples

```js
var qs = require('qs');

qs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');
// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } }

qs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }})
// => user[name]=Tobi&user[email]=tobi%40learnboost.com
```

## Testing

Install dev dependencies:

$ npm install -d

and execute:

$ make test

## License

(The MIT License)

Copyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions deps/qs/benchmark.js
@@ -0,0 +1,17 @@

var qs = require('./');

var times = 100000
, start = new Date
, n = times;

console.log('times: %d', times);

while (n--) qs.parse('foo=bar');
console.log('simple: %dms', new Date - start);

var start = new Date
, n = times;

while (n--) qs.parse('user[name][first]=tj&user[name][last]=holowaychuk');
console.log('nested: %dms', new Date - start);
51 changes: 51 additions & 0 deletions deps/qs/examples.js
@@ -0,0 +1,51 @@

/**
* Module dependencies.
*/

var qs = require('./');

var obj = qs.parse('foo');
console.log(obj)

var obj = qs.parse('foo=bar=baz');
console.log(obj)

var obj = qs.parse('users[]');
console.log(obj)

var obj = qs.parse('name=tj&email=tj@vision-media.ca');
console.log(obj)

var obj = qs.parse('users[]=tj&users[]=tobi&users[]=jane');
console.log(obj)

var obj = qs.parse('user[name][first]=tj&user[name][last]=holowaychuk');
console.log(obj)

var obj = qs.parse('users[][name][first]=tj&users[][name][last]=holowaychuk');
console.log(obj)

var obj = qs.parse('a=a&a=b&a=c');
console.log(obj)

var obj = qs.parse('user[tj]=tj&user[tj]=TJ');
console.log(obj)

var obj = qs.parse('user[names]=tj&user[names]=TJ&user[names]=Tyler');
console.log(obj)

var obj = qs.parse('user[name][first]=tj&user[name][first]=TJ');
console.log(obj)

var obj = qs.parse('user[0]=tj&user[1]=TJ');
console.log(obj)

var obj = qs.parse('user[0]=tj&user[]=TJ');
console.log(obj)

var obj = qs.parse('user[0]=tj&user[foo]=TJ');
console.log(obj)

var str = qs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }});
console.log(str);
2 changes: 2 additions & 0 deletions deps/qs/index.js
@@ -0,0 +1,2 @@

module.exports = require('./lib/querystring');

0 comments on commit 4d275a1

Please sign in to comment.