Module 466107

5,883 characters · in 52082.07941602b067c1b4.js
Dependencies
Required by (1)
Lazily required by (0)none
Requires (1)
Lazily requires (0)none
Source Raw
function(t,e,r){"use strict";var o=r(589841),n=Object.prototype.hasOwnProperty,i=Array.isArray,a={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:o.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},s=function(t,e,r){if(t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1)return t.split(",");if(e.throwOnLimitExceeded&&r>=e.arrayLimit)throw RangeError("Array limit exceeded. Only "+e.arrayLimit+" element"+(1===e.arrayLimit?"":"s")+" allowed in an array.");return t},l=function(t,e){var r={__proto__:null},l=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;l=l.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var p=e.parameterLimit===1/0?void 0:e.parameterLimit,c=l.split(e.delimiter,e.throwOnLimitExceeded?p+1:p);if(e.throwOnLimitExceeded&&c.length>p)throw RangeError("Parameter limit exceeded. Only "+p+" parameter"+(1===p?"":"s")+" allowed.");var u=-1,f=e.charset;if(e.charsetSentinel)for(y=0;y<c.length;++y)0===c[y].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[y]?f="utf-8":"utf8=%26%2310003%3B"===c[y]&&(f="iso-8859-1"),u=y,y=c.length);for(y=0;y<c.length;++y)if(y!==u){var y,h,d,m=c[y],b=m.indexOf("]="),g=-1===b?m.indexOf("="):b+1;-1===g?(h=e.decoder(m,a.decoder,f,"key"),d=e.strictNullHandling?null:""):(h=e.decoder(m.slice(0,g),a.decoder,f,"key"),d=o.maybeMap(s(m.slice(g+1),e,i(r[h])?r[h].length:0),function(t){return e.decoder(t,a.decoder,f,"value")})),d&&e.interpretNumericEntities&&"iso-8859-1"===f&&(d=String(d).replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})),m.indexOf("[]=")>-1&&(d=i(d)?[d]:d);var v=n.call(r,h);v&&"combine"===e.duplicates?r[h]=o.combine(r[h],d):v&&"last"!==e.duplicates||(r[h]=d)}return r},p=function(t,e,r,n){var i=0;if(t.length>0&&"[]"===t[t.length-1]){var a=t.slice(0,-1).join("");i=Array.isArray(e)&&e[a]?e[a].length:0}for(var l=n?e:s(e,r,i),p=t.length-1;p>=0;--p){var c,u=t[p];if("[]"===u&&r.parseArrays)c=r.allowEmptyArrays&&(""===l||r.strictNullHandling&&null===l)?[]:o.combine([],l);else{c=r.plainObjects?{__proto__:null}:{};var f="["===u.charAt(0)&&"]"===u.charAt(u.length-1)?u.slice(1,-1):u,y=r.decodeDotInKeys?f.replace(/%2E/g,"."):f,h=parseInt(y,10);r.parseArrays||""!==y?!isNaN(h)&&u!==y&&String(h)===y&&h>=0&&r.parseArrays&&h<=r.arrayLimit?(c=[])[h]=l:"__proto__"!==y&&(c[y]=l):c={0:l}}l=c}return l},c=function(t,e,r,o){if(t){var i=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/g,s=r.depth>0&&/(\[[^[\]]*])/.exec(i),l=s?i.slice(0,s.index):i,c=[];if(l){if(!r.plainObjects&&n.call(Object.prototype,l)&&!r.allowPrototypes)return;c.push(l)}for(var u=0;r.depth>0&&null!==(s=a.exec(i))&&u<r.depth;){if(u+=1,!r.plainObjects&&n.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(s[1])}if(s){if(!0===r.strictDepth)throw RangeError("Input depth exceeded depth option of "+r.depth+" and strictDepth is true");c.push("["+i.slice(s.index)+"]")}return p(c,e,r,o)}},u=function(t){if(!t)return a;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.decodeDotInKeys&&"boolean"!=typeof t.decodeDotInKeys)throw TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==t.throwOnLimitExceeded&&"boolean"!=typeof t.throwOnLimitExceeded)throw TypeError("`throwOnLimitExceeded` option must be a boolean");var e=void 0===t.charset?a.charset:t.charset,r=void 0===t.duplicates?a.duplicates:t.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===t.allowDots?!0===t.decodeDotInKeys||a.allowDots:!!t.allowDots,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:a.allowEmptyArrays,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:a.allowPrototypes,allowSparse:"boolean"==typeof t.allowSparse?t.allowSparse:a.allowSparse,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:a.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:a.comma,decodeDotInKeys:"boolean"==typeof t.decodeDotInKeys?t.decodeDotInKeys:a.decodeDotInKeys,decoder:"function"==typeof t.decoder?t.decoder:a.decoder,delimiter:"string"==typeof t.delimiter||o.isRegExp(t.delimiter)?t.delimiter:a.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:a.depth,duplicates:r,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:a.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:a.plainObjects,strictDepth:"boolean"==typeof t.strictDepth?!!t.strictDepth:a.strictDepth,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:a.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof t.throwOnLimitExceeded&&t.throwOnLimitExceeded}};t.exports=function(t,e){var r=u(e);if(""===t||null==t)return r.plainObjects?{__proto__:null}:{};for(var n="string"==typeof t?l(t,r):t,i=r.plainObjects?{__proto__:null}:{},a=Object.keys(n),s=0;s<a.length;++s){var p=a[s],f=c(p,n[p],r,"string"==typeof t);i=o.merge(i,f,r)}return!0===r.allowSparse?i:o.compact(i)}}