forked from geddy/geddy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do the right thing when parsing query strings
- Loading branch information
Techwraith
committed
Mar 7, 2012
1 parent
f0ab51b
commit 4d275a1
Showing
17 changed files
with
779 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- 0.6 | ||
- 0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
test: | ||
@./node_modules/.bin/mocha | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
module.exports = require('./lib/querystring'); |
Oops, something went wrong.