UNPKG

url-params-helper

Version:

A helper for URL parameters/query strings.

2 lines 1.59 kB
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("url-params",[],n):"object"==typeof exports?exports["url-params"]=n():e["url-params"]=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n){"use strict";function t(e){for(var n=e||window.location.href,t=n.split("?")[1],r="string"==typeof t&&t.length>0?t.split("&"):"",o={},u=0;u<r.length;u++){var i=r[u],a=i.split("="),p=a[0],l=a[1];-1===p.indexOf("[]")?l&&""!==l&&(o[p]=decodeURIComponent(l)):(p=p.replace(/[\[|\]]/g,""),void 0===o[p]&&(o[p]=[]),o[p].push(decodeURIComponent(l)))}return Object.keys(o).length>0?o:null}function r(e,n){var r=t(n);return r?r[e]:null}function o(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&!function(){var r=encodeURIComponent(t),o=e[t];void 0!==o&&(o instanceof Array?o.map(function(e){n.push(r+"[]="+(void 0===e||null===e?"":encodeURIComponent(e)))}):n.push(r+"="+(null===o?"":encodeURIComponent(o))))}();return n.join("&")}function u(e,n){var t=(n||window.location.href).split("?")[0],r=o(e);return t+(r.length>0?"?"+r:"")}function i(e,n,r){var o=t(r)||{};return o[e]=n,u(o,r)}function a(e,n){var r=t(n)||{};return delete r[e],u(r,n)}Object.defineProperty(n,"__esModule",{value:!0}),n.getParams=t,n.getParam=r,n.buildQueryString=o,n.buildQueryStringURL=u,n.replaceParam=i,n.removeParam=a}])}); //# sourceMappingURL=url-params.min.js.map