@@ -10,35 +10,17 @@ var qs = require("querystring");
1010var qsTestCases = [
1111 [ "foo=918854443121279438895193" , "foo=918854443121279438895193" , { "foo" : "918854443121279438895193" } ] ,
1212 [ "foo=bar" , "foo=bar" , { "foo" : "bar" } ] ,
13- [ "foo=bar&foo=quux" , "foo%5B%5D =bar&foo%5B%5D =quux" , { "foo" : [ "bar" , "quux" ] } ] ,
13+ [ "foo=bar&foo=quux" , "foo=bar&foo=quux" , { "foo" : [ "bar" , "quux" ] } ] ,
1414 [ "foo=1&bar=2" , "foo=1&bar=2" , { "foo" : "1" , "bar" : "2" } ] ,
1515 [ "my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F" , "my%20weird%20field=q1!2%22'w%245%267%2Fz8)%3F" , { "my weird field" : "q1!2\"'w$5&7/z8)?" } ] ,
1616 [ "foo%3Dbaz=bar" , "foo%3Dbaz=bar" , { "foo=baz" : "bar" } ] ,
1717 [ "foo=baz=bar" , "foo=baz%3Dbar" , { "foo" : "baz=bar" } ] ,
18- [ "str=foo&arr[] =1&arr[] =2&arr[] =3&obj[a]=bar&obj[b][]=4&obj[b][]=5&obj[b][]=6&obj[b][]=&obj[c][]=4&obj[c][]=5&obj[c][][somestr]=baz&obj[objobj][objobjstr]=blerg& somenull=&undef=" , "str=foo&arr%5B%5D =1&arr%5B%5D =2&arr%5B%5D=3&obj%5Ba%5D=bar&obj%5Bb%5D%5B%5D=4&obj%5Bb%5D%5B%5D=5&obj%5Bb%5D%5B%5D=6&obj%5Bb%5D%5B%5D=&obj%5Bc%5D%5B%5D=4&obj%5Bc%5D%5B%5D=5&obj%5Bc%5D%5B%5D%5Bsomestr%5D=baz&obj%5Bobjobj%5D%5Bobjobjstr%5D=blerg &somenull=&undef=" , {
18+ [ "str=foo&arr=1&arr=2&arr=3&somenull=&undef=" , "str=foo&arr=1&arr=2&arr=3 &somenull=&undef=" , {
1919 "str" :"foo" ,
2020 "arr" :[ "1" , "2" , "3" ] ,
21- "obj" :{
22- "a" :"bar" ,
23- "b" :[ "4" , "5" , "6" , "" ] ,
24- "c" :[ "4" , "5" , { "somestr" :"baz" } ] ,
25- "objobj" :{ "objobjstr" :"blerg" }
26- } ,
2721 "somenull" :"" ,
2822 "undef" :""
2923 } ] ,
30- [ "foo[bar][bla]=baz&foo[bar][bla]=blo" , "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo" , { "foo" :{ "bar" :{ "bla" :[ "baz" , "blo" ] } } } ] ,
31- [ "foo[bar][][bla]=baz&foo[bar][][bla]=blo" , "foo%5Bbar%5D%5B%5D%5Bbla%5D=baz&foo%5Bbar%5D%5B%5D%5Bbla%5D=blo" , { "foo" :{ "bar" :[ { "bla" :"baz" } , { "bla" :"blo" } ] } } ] ,
32- [ "foo[bar][bla][]=baz&foo[bar][bla][]=blo" , "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo" , { "foo" :{ "bar" :{ "bla" :[ "baz" , "blo" ] } } } ] ,
33-
34- [ "foo.bar.bla=baz&foo.bar.bla=blo" , "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo" , { "foo" :{ "bar" :{ "bla" :[ "baz" , "blo" ] } } } ] ,
35- [ "foo.bar[].bla=baz&foo[bar][][bla]=blo" , "foo%5Bbar%5D%5B%5D%5Bbla%5D=baz&foo%5Bbar%5D%5B%5D%5Bbla%5D=blo" , { "foo" :{ "bar" :[ { "bla" :"baz" } , { "bla" :"blo" } ] } } ] ,
36- [ "foo[bar].bla[]=baz&foo.bar[bla][]=blo" , "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo" , { "foo" :{ "bar" :{ "bla" :[ "baz" , "blo" ] } } } ] ,
37-
38- [ "foo['bar']['bla']=baz&foo[\"bar\"][\"bla\"]=blo" , "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo" , { "foo" :{ "bar" :{ "bla" :[ "baz" , "blo" ] } } } ] ,
39- [ "foo['bar'][]['bla']=baz&foo['bar'][][\"bla\"]=blo" , "foo%5Bbar%5D%5B%5D%5Bbla%5D=baz&foo%5Bbar%5D%5B%5D%5Bbla%5D=blo" , { "foo" :{ "bar" :[ { "bla" :"baz" } , { "bla" :"blo" } ] } } ] ,
40- [ "foo[bar][\"bla\"][]=baz&foo[\"bar\"][bla][]=blo" , "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo" , { "foo" :{ "bar" :{ "bla" :[ "baz" , "blo" ] } } } ] ,
41-
4224 [ " foo = bar " , "%20foo%20=%20bar%20" , { " foo " :" bar " } ] ,
4325 [ "foo=%zx" , "foo=%25zx" , { "foo" :"%zx" } ] ,
4426 [ "foo=%EF%BF%BD" , "foo=%EF%BF%BD" , { "foo" : "\ufffd" } ]
@@ -47,7 +29,7 @@ var qsTestCases = [
4729// [ wonkyQS, canonicalQS, obj ]
4830var qsColonTestCases = [
4931 [ "foo:bar" , "foo:bar" , { "foo" :"bar" } ] ,
50- [ "foo:bar;foo:quux" , "foo%5B%5D :bar;foo%5B%5D :quux" , { "foo" : [ "bar" , "quux" ] } ] ,
32+ [ "foo:bar;foo:quux" , "foo:bar;foo:quux" , { "foo" : [ "bar" , "quux" ] } ] ,
5133 [ "foo:1&bar:2;baz:quux" , "foo:1%26bar%3A2;baz:quux" , { "foo" :"1&bar:2" , "baz" :"quux" } ] ,
5234 [ "foo%3Abaz:bar" , "foo%3Abaz:bar" , { "foo:baz" :"bar" } ] ,
5335 [ "foo:baz:bar" , "foo:baz%3Abar" , { "foo" :"baz:bar" } ]
@@ -65,8 +47,8 @@ var qsWeirdObjects = [
6547 [ { e :extendedFunction } , "e=" , { "e" :"" } ] ,
6648 [ { d :new Date ( ) } , "d=" , { "d" :"" } ] ,
6749 [ { d :Date } , "d=" , { "d" :"" } ] ,
68- [ { f :new Boolean ( false ) , t :new Boolean ( true ) } , "f=0 &t=1 " , { "f" :"0 " , "t" :"1 " } ] ,
69- [ { f :false , t :true } , "f=0 &t=1 " , { "f" :"0 " , "t" :"1 " } ] ,
50+ [ { f :new Boolean ( false ) , t :new Boolean ( true ) } , "f=&t=" , { "f" :"" , "t" :"" } ] ,
51+ [ { f :false , t :true } , "f=false &t=true " , { "f" :"false " , "t" :"true " } ] ,
7052 [ { n :null } , "n=" , { "n" :"" } ] ,
7153 [ { nan :NaN } , "nan=" , { "nan" :"" } ] ,
7254 [ { inf :Infinity } , "inf=" , { "inf" :"" } ]
@@ -84,7 +66,7 @@ var qsNoMungeTestCases = [
8466 [ "gragh=1&gragh=3&goo=2" , { "gragh" : [ "1" , "3" ] , "goo" : "2" } ] ,
8567 [ "frappucino=muffin&goat%5B%5D=scone&pond=moose" ,
8668 { "frappucino" : "muffin" , "goat[]" : "scone" , "pond" : "moose" } ] ,
87- [ "obj%5Btrololol%5D =yes&obj%5Blololo%5D =no" , { "obj" : { " trololol" : "yes" , "lololo" : "no" } } ]
69+ [ "trololol =yes&lololo =no" , { "trololol" : "yes" , "lololo" : "no" } ]
8870] ;
8971
9072assert . strictEqual ( "918854443121279438895193" , qs . parse ( "id=918854443121279438895193" ) . id ) ;
@@ -123,11 +105,6 @@ qsNoMungeTestCases.forEach(function (testCase) {
123105} ) ( ) ;
124106
125107// now test stringifying
126- assert . throws ( function ( ) {
127- var f = { } ;
128- f . f = f ;
129- qs . stringify ( f ) ;
130- } ) ;
131108
132109// basic
133110qsTestCases . forEach ( function ( testCase ) {
0 commit comments