forked from jillix/url.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl.min.js
1 lines (1 loc) · 2.36 KB
/
url.min.js
1
"use strict";function _typeof(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}!function(e){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.Url=e()}}(function(){return function e(n,o,t){function r(a,u){if(!o[a]){if(!n[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var l=o[a]={exports:{}};n[a][0].call(l.exports,function(e){var o=n[a][1][e];return r(o?o:e)},l,l.exports,e,n,o,t)}return o[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)r(t[a]);return r}({1:[function(e,n){n.exports={queryString:function(e,n){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var o=new RegExp("[\\?&]"+e+"=([^&#]*)"),t=o.exec(location.search),r=null;return null===t?(o=new RegExp("[\\?&]"+e+"(\\&([^&#]*)|$)"),o.test(location.search)?!0:void 0):(r=t[1].replace(/\+/g," "),n?r:decodeURIComponent(r))},parseQuery:function(e){var n={};if("string"!=typeof e&&(e=window.location.search),e=e.replace(/^\?/g,""),!e)return{};for(var o,t=e.split("&"),r=0,i=null;r<t.length;++r)o=t[r].indexOf("="),0>o?(o=t[r].length,i=!0):i=decodeURIComponent(t[r].slice(o+1)),n[decodeURIComponent(t[r].slice(0,o))]=i;return n},stringify:function(e){if(!e||e.constructor!==Object)throw new Error("Query object should be an object.");var n="";return Object.keys(e).forEach(function(o){var t=e[o];n+=o,t!==!0&&(n+="="+encodeURIComponent(e[o])),n+="&"}),n=n.replace(/\&$/g,"")},updateSearchParam:function(e,n,o){var t=this.parseQuery();if(void 0===n)delete t[e];else{if(t[e]===n)return Url;t[e]=n}var r="?"+this.stringify(t);return this._updateAll(window.location.pathname+r+location.hash,o),Url},getLocation:function(){return window.location.pathname+window.location.search+window.location.hash},hash:function(e){return void 0===e?location.hash.substring(1):location.hash=e},_updateAll:function(e,n){return window.history[n?"pushState":"replaceState"](null,"",e),e},pathname:function(e,n){return void 0===e?location.pathname:this._updateAll(e+window.location.search+window.location.hash,n)},version:"2.1.0"}},{}]},{},[1])(1)});