PageSourceSearch

https://www.sfasu.edu/themes/custom/sfa/vendor/jquery-deparam.js?tltm25

js sfasu.edu collected 2026-09-24 08:44:44 UTC 4,824 bytes, 112 lines download raw bytes

1(function(deparam){
2    if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
3        var jquery = require('jquery');
4        module.exports = deparam(jquery);
5    } else if (typeof define === 'function' && define.amd){
6        define(['jquery'], function(jquery){
7            return deparam(jquery);
8        });
9    } else {
10        var global
11        try {
12          global = (false || eval)('this'); // best cross-browser way to determine global for < ES5
13        } catch (e) {
14          global = window; // fails only if browser (https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives)
15        }
16        global.deparam = deparam(jQuery); // assume jQuery is in global namespace
17    }
18})(function ($) {
19    var deparam = function( params, coerce ) {
20        var obj = {},
21        coerce_types = { 'true': !0, 'false': !1, 'null': null };
22
23        // Iterate over all name=value pairs.
24        params.replace(/\+/g, ' ').split('&').forEach(function(v){
25            var param = v.split( '=' ),
26            key = decodeURIComponent( param[0] ),
27            val,
28            cur = obj,
29            i = 0,
30
31            // If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
32            // into its component parts.
33            keys = key.split( '][' ),
34            keys_last = keys.length - 1;
35
36            // If the first keys part contains [ and the last ends with ], then []
37            // are correctly balanced.
38            if ( /\[/.test( keys[0] ) && /\]$/.test( keys[ keys_last ] ) ) {
39                // Remove the trailing ] from the last keys part.
40                keys[ keys_last ] = keys[ keys_last ].replace( /\]$/, '' );
41
42                // Split first keys part into two parts on the [ and add them back onto
43                // the beginning of the keys array.
44                keys = keys.shift().split('[').concat( keys );
45
46                keys_last = keys.length - 1;
47            } else {
48                // Basic 'foo' style key.
49                keys_last = 0;
50            }
51
52            // Are we dealing with a name=value pair, or just a name?
53            if ( param.length === 2 ) {
54                val = decodeURIComponent( param[1] );
55
56                // Coerce values.
57                if ( coerce ) {
58                    val = val && !isNaN(val) && ((+val + '') === val) ? +val        // number
59                    : val === 'undefined'                       ? undefined         // undefined
60                    : coerce_types[val] !== undefined           ? coerce_types[val] // true, false, null
61                    : val;                                                          // string
62                }
63
64                if ( keys_last ) {
65                    // Complex key, build deep object structure based on a few rules:
66                    // * The 'cur' pointer starts at the object top-level.
67                    // * [] = array push (n is set to array length), [n] = array if n is
68                    //   numeric, otherwise object.
69                    // * If at the last keys part, set the value.
70                    // * For each keys part, if the current level is undefined create an
71                    //   object or array based on the type of the next keys part.
72                    // * Move the 'cur' pointer to the next level.
73                    // * Rinse & repeat.
74                    for ( ; i <= keys_last; i++ ) {
75                        key = keys[i] === '' ? cur.length : keys[i];
76                        cur = cur[key] = i < keys_last
77                        ? cur[key] || ( keys[i+1] && isNaN( keys[i+1] ) ? {} : [] )
78                        : val;
79                    }
80
81                } else {
82                    // Simple key, even simpler rules, since only scalars and shallow
83                    // arrays are allowed.
84
85                    if ( Object.prototype.toString.call( obj[key] ) === '[object Array]' ) {
86                        // val is already an array, so push on the next value.
87                        obj[key].push( val );
88
89                    } else if ( {}.hasOwnProperty.call(obj, key) ) {
90                        // val isn't an array, but since a second value has been specified,
91                        // convert val into an array.
92                        obj[key] = [ obj[key], val ];
93
94                    } else {
95                        // val is a scalar.
96                        obj[key] = val;
97                    }
98                }
99
100            } else if ( key ) {
101                // No value was defined, so set something meaningful.
102                obj[key] = coerce
103                ? undefined
104                : '';
105            }
106        });
107
108        return obj;
109    };
110    $.prototype.deparam = $.deparam = deparam;
111    return deparam;
112});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.