1
/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
2
YUI.add('querystring-stringify-simple', function (Y, NAME) {
6
* <p>Provides Y.QueryString.stringify method for converting objects to Query Strings.
7
* This is a subset implementation of the full querystring-stringify.</p>
8
* <p>This module provides the bare minimum functionality (encoding a hash of simple values),
9
* without the additional support for nested data structures. Every key-value pair is
10
* encoded by encodeURIComponent.</p>
11
* <p>This module provides a minimalistic way for io to handle single-level objects
12
* as transaction data.</p>
15
* @submodule querystring-stringify-simple
18
var QueryString = Y.namespace("QueryString"),
19
EUC = encodeURIComponent;
22
QueryString.stringify = function (obj, c) {
24
// Default behavior is false; standard key notation.
25
s = c && c.arrayKey ? true : false,
29
if (obj.hasOwnProperty(key)) {
30
if (Y.Lang.isArray(obj[key])) {
31
for (i = 0, l = obj[key].length; i < l; i++) {
32
qs.push(EUC(s ? key + '[]' : key) + '=' + EUC(obj[key][i]));
36
qs.push(EUC(key) + '=' + EUC(obj[key]));
45
}, '3.9.1', {"requires": ["yui-base"]});