You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
2 years ago
|
/*
|
||
|
YUI 3.17.2 (build 9c3c78e)
|
||
|
Copyright 2014 Yahoo! Inc. All rights reserved.
|
||
|
Licensed under the BSD License.
|
||
|
http://yuilibrary.com/license/
|
||
|
*/
|
||
|
|
||
|
YUI.add('querystring-stringify-simple', function (Y, NAME) {
|
||
|
|
||
|
/*global Y */
|
||
|
/**
|
||
|
* <p>Provides Y.QueryString.stringify method for converting objects to Query Strings.
|
||
|
* This is a subset implementation of the full querystring-stringify.</p>
|
||
|
* <p>This module provides the bare minimum functionality (encoding a hash of simple values),
|
||
|
* without the additional support for nested data structures. Every key-value pair is
|
||
|
* encoded by encodeURIComponent.</p>
|
||
|
* <p>This module provides a minimalistic way for io to handle single-level objects
|
||
|
* as transaction data.</p>
|
||
|
*
|
||
|
* @module querystring
|
||
|
* @submodule querystring-stringify-simple
|
||
|
*/
|
||
|
|
||
|
var QueryString = Y.namespace("QueryString"),
|
||
|
EUC = encodeURIComponent;
|
||
|
|
||
|
|
||
|
QueryString.stringify = function (obj, c) {
|
||
|
var qs = [],
|
||
|
// Default behavior is false; standard key notation.
|
||
|
s = c && c.arrayKey ? true : false,
|
||
|
key, i, l;
|
||
|
|
||
|
for (key in obj) {
|
||
|
if (obj.hasOwnProperty(key)) {
|
||
|
if (Y.Lang.isArray(obj[key])) {
|
||
|
for (i = 0, l = obj[key].length; i < l; i++) {
|
||
|
qs.push(EUC(s ? key + '[]' : key) + '=' + EUC(obj[key][i]));
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
qs.push(EUC(key) + '=' + EUC(obj[key]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return qs.join('&');
|
||
|
};
|
||
|
|
||
|
|
||
|
}, '3.17.2', {"requires": ["yui-base"]});
|