-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquery.min.js
1 lines (1 loc) · 1.38 KB
/
query.min.js
1
!function(e){"use strict";function n(){}n.get=function(e,n,t,r){if(e){var o=new RegExp("[?&]"+n+"=([^&]*)"),u=e.match(o);return u&&u.length>1?r?u[1]:decodeURIComponent(u[1]):t}},n.getAll=function(e,n){if(!e)return{};var t={},r=e.indexOf("?");if(e.length>1&&r>=0)for(var o=e.substring(r+1).split("&"),u=0;u<o.length;u++){var i=o[u].split("=");2===i.length&&(t[i[0]]=n?i[1]:decodeURIComponent(i[1]))}return t},n.update=function(e,n,t,r){if(void 0===e)return e;var o=new RegExp("([?&])"+n+"=[^&]*"),u=e.match(o);if(u&&u.length>1)return e.replace(o,"$1"+n+"="+(r?t:encodeURIComponent(t)));var i=e.indexOf("?")>0?"&":"?";return e+i+n+"="+(r?t:encodeURIComponent(t))},n.updateAll=function(e,t,r,o){if(void 0===e||!t||!r)return e;if(t.length!==r.length)return e;for(var u=e,i=0;i<t.length;i++)u=n.update(u,t[i],r[i],o);return u},n.remove=function(e,n){if(void 0===e)return e;var t=new RegExp("[&]"+n+"=[^&]*");return e.match(t)?e.replace(t,""):(t=new RegExp("[?]"+n+"=[^&]*$"),e.match(t)?e.replace(t,""):(t=new RegExp("[?]"+n+"=[^&]*&"),e.match(t)?e.replace(t,"?"):e))},n.removeAll=function(e,t){if(void 0===e||!t)return e;for(var r=e,o=0;o<t.length;o++)r=n.remove(r,t[o]);return r},"object"==typeof e&&(e.UrlQuery=n),"function"==typeof define&&define.amd?define(function(){return n}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(module.exports=n),exports.UrlQuery=n):e.UrlQuery=n}(this);