Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('querystring-parse-simple', function (Y, NAME) {
2
 
3
// @TODO this looks like we are requiring the user to extract the querystring
4
// portion of the url, which isn't good.  The majority use case will be to
5
// extract querystring from the document configured for this YUI instance.
6
// This should be the default if qs is not supplied.
7
 
8
/*global Y */
9
/**
10
 * <p>Provides Y.QueryString.parse method for converting Query Strings to an object.
11
 * This is a simpler implementation than the full querystring-parse.</p>
12
 * <p>Because some things may require basic query string escaping functionality,
13
 * this module provides the bare minimum functionality (decoding a hash of simple values),
14
 * without the additional support for arrays, objects, and so on.</p>
15
 * <p>This provides a friendly way to deserialize basic query strings, without necessitating
16
 * a lot of code for simple use-cases.</p>
17
 *
18
 * @module querystring
19
 * @submodule querystring-parse-simple
20
 */
21
 
22
var QueryString = Y.namespace("QueryString");
23
 
24
QueryString.parse = function (qs, sep, eq) {
25
    sep = sep || "&";
26
    eq = eq || "=";
27
    for (
28
        var obj = {},
29
            i = 0,
30
            pieces = qs.split(sep),
31
            l = pieces.length,
32
            tuple;
33
        i < l;
34
        i ++
35
    ) {
36
        tuple = pieces[i].split(eq);
37
        if (tuple.length > 0) {
38
            obj[QueryString.unescape(tuple.shift())] = QueryString.unescape(tuple.join(eq));
39
        }
40
    }
41
    return obj;
42
};
43
 
44
QueryString.unescape = function (s) {
45
    return decodeURIComponent(s.replace(/\+/g, ' '));
46
};
47
 
48
 
49
}, '3.18.1', {"requires": ["yui-base"]});