| 130833 | encode(value, opts) |
| 130834 | ].join(''); |
| 130835 | }; |
| 130836 | |
| 130837 | case 'bracket': |
| 130838 | return function (key, value) { |
| 130839 | return value === null ? encode(key, opts) : [ |
| 130840 | encode(key, opts), |
| 130841 | '[]=', |
| 130842 | encode(value, opts) |
| 130843 | ].join(''); |
| 130844 | }; |
| 130845 | |
| 130846 | default: |
| 130847 | return function (key, value) { |
| 130848 | return value === null ? encode(key, opts) : [ |
| 130849 | encode(key, opts), |
| 130850 | '=', |
| 130851 | encode(value, opts) |
| 130852 | ].join(''); |
| 130853 | }; |
| 130854 | } |
| 130855 | } |
| 130856 | |
| 130857 | function parserForArrayFormat(opts) { |
| 130858 | var result; |
| 130859 | |
| 130860 | switch (opts.arrayFormat) { |
| 130861 | case 'index': |
| 130862 | return function (key, value, accumulator) { |
| 130863 | result = /\[(\d*)\]$/.exec(key); |
| 130864 | |
| 130865 | key = key.replace(/\[\d*\]$/, ''); |
| 130866 | |
| 130867 | if (!result) { |
| 130868 | accumulator[key] = value; |
| 130869 | return; |
| 130870 | } |
| 130871 | |
| 130872 | if (accumulator[key] === undefined) { |
| 130873 | accumulator[key] = {}; |
| 130874 | } |
| 130875 | |
| 130876 | accumulator[key][result[1]] = value; |
| 130877 | }; |
| 130878 | |
| 130879 | case 'bracket': |
| 130880 | return function (key, value, accumulator) { |
| 130881 | result = /(\[\])$/.exec(key); |
| 130882 | key = key.replace(/\[\]$/, ''); |
| 130883 | |
| 130884 | if (!result) { |
| 130885 | accumulator[key] = value; |
| 130886 | return; |