query-stringify.js
4.94 KB
// github: https://github.com/sindresorhus/query-string
// update: https://wzrd.in/standalone/query-string@latest
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.queryString=e()}}(function(){return function e(r,n,t){function o(c,u){if(!n[c]){if(!r[c]){var a="function"==typeof require&&require;if(!u&&a)return a(c,!0);if(i)return i(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[c]={exports:{}};r[c][0].call(s.exports,function(e){var n=r[c][1][e];return o(n?n:e)},s,s.exports,e,r,n,t)}return n[c].exports}for(var i="function"==typeof require&&require,c=0;c<t.length;c++)o(t[c]);return o}({1:[function(e,r,n){"use strict";function t(e){switch(e.arrayFormat){case"index":return function(r,n,t){return null===n?[i(r,e),"[",t,"]"].join(""):[i(r,e),"[",i(t,e),"]=",i(n,e)].join("")};case"bracket":return function(r,n){return null===n?i(r,e):[i(r,e),"[]=",i(n,e)].join("")};default:return function(r,n){return null===n?i(r,e):[i(r,e),"=",i(n,e)].join("")}}}function o(e){var r;switch(e.arrayFormat){case"index":return function(e,n,t){return r=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),r?(void 0===t[e]&&(t[e]={}),void(t[e][r[1]]=n)):void(t[e]=n)};case"bracket":return function(e,n,t){return r=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),r?void 0===t[e]?void(t[e]=[n]):void(t[e]=[].concat(t[e],n)):void(t[e]=n)};default:return function(e,r,n){return void 0===n[e]?void(n[e]=r):void(n[e]=[].concat(n[e],r))}}}function i(e,r){return r.encode?r.strict?u(e):encodeURIComponent(e):e}function c(e){return Array.isArray(e)?e.sort():"object"==typeof e?c(Object.keys(e)).sort(function(e,r){return Number(e)-Number(r)}).map(function(r){return e[r]}):e}var u=e("strict-uri-encode"),a=e("object-assign"),f=e("decode-uri-component");n.extract=function(e){var r=e.indexOf("?");return r===-1?"":e.slice(r+1)},n.parse=function(e,r){r=a({arrayFormat:"none"},r);var n=o(r),t=Object.create(null);return"string"!=typeof e?t:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var r=e.replace(/\+/g," ").split("="),o=r.shift(),i=r.length>0?r.join("="):void 0;i=void 0===i?null:f(i),n(f(o),i,t)}),Object.keys(t).sort().reduce(function(e,r){var n=t[r];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[r]=c(n):e[r]=n,e},Object.create(null))):t},n.stringify=function(e,r){var n={encode:!0,strict:!0,arrayFormat:"none"};r=a(n,r);var o=t(r);return e?Object.keys(e).sort().map(function(n){var t=e[n];if(void 0===t)return"";if(null===t)return i(n,r);if(Array.isArray(t)){var c=[];return t.slice().forEach(function(e){void 0!==e&&c.push(o(n,e,c.length))}),c.join("&")}return i(n,r)+"="+i(t,r)}).filter(function(e){return e.length>0}).join("&"):""}},{"decode-uri-component":2,"object-assign":3,"strict-uri-encode":4}],2:[function(e,r,n){"use strict";function t(e,r){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;r=r||1;var n=e.slice(0,r),o=e.slice(r);return Array.prototype.concat.call([],t(n),t(o))}function o(e){try{return decodeURIComponent(e)}catch(o){for(var r=e.match(u),n=1;n<r.length;n++)e=t(r,n).join(""),r=e.match(u);return e}}function i(e){for(var r={"%FE%FF":"��","%FF%FE":"��"},n=a.exec(e);n;){try{r[n[0]]=decodeURIComponent(n[0])}catch(e){var t=o(n[0]);t!==n[0]&&(r[n[0]]=t)}n=a.exec(e)}r["%C2"]="�";for(var i=Object.keys(r),c=0;c<i.length;c++){var u=i[c];e=e.replace(new RegExp(u,"g"),r[u])}return e}var c="%[a-f0-9]{2}",u=new RegExp(c,"gi"),a=new RegExp("("+c+")+","gi");r.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(r){return i(e)}}},{}],3:[function(e,r,n){"use strict";function t(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function o(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var r={},n=0;n<10;n++)r["_"+String.fromCharCode(n)]=n;var t=Object.getOwnPropertyNames(r).map(function(e){return r[e]});if("0123456789"!==t.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}var i=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;r.exports=o()?Object.assign:function(e,r){for(var n,o,a=t(e),f=1;f<arguments.length;f++){n=Object(arguments[f]);for(var s in n)c.call(n,s)&&(a[s]=n[s]);if(i){o=i(n);for(var d=0;d<o.length;d++)u.call(n,o[d])&&(a[o[d]]=n[o[d]])}}return a}},{}],4:[function(e,r,n){"use strict";r.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}]},{},[1])(1)});