-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjQuery.ddUrl.min.js
2 lines (2 loc) · 1.86 KB
/
jQuery.ddUrl.min.js
1
2
/* jQuery.ddUrl v2.1.1 (2023-10-05) | © https://Ronef.ru */
!function(r){r.ddUrl={current:{},parseQuery:function(t){function o(r,t,o){Array.isArray(r[t])?r[t].push(o):r[t]=o}function n(t,e,a,i){var s=t.shift();s?(e[a]||(e[a]=[]),"]"==s?o(e,a,i):(-1!=s.indexOf("]")&&(s=s.substr(0,s.length-1)),!r.isNumeric(s)&&Array.isArray(e[a])&&(e[a]=function(r){var t={};return r.forEach((([r,o])=>{t[r]=o})),t}(e[a])),n(t,e[a],s,i))):o(e,a,i)}var e={result:{}};if(t.length>0){t=t.split("&");for(var a=0;a<t.length;a++){var i=t[a].split("="),s=i[0],h=i[1]||"";-1==s.indexOf("[")?o(e.result,s,h):n(s.split("["),e,"result",h)}}return e.result},parsePath:function(t){var o=[];t=t.split("/");for(var n=0;n<t.length;n++){var e=r.trim(t[n]);0!=e.length&&o.push(e)}return o},parse:function(r){var t=this;"string"!=typeof r&&(r=window.location.toString());var o=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(decodeURI(r)),n={full:"",origin:"",protocol:o[1]||window.location.protocol.replace(":",""),host:o[6]||"",port:o[7]||"",relative:o[8],path:o[9],queryString:o[12]||"",queryObject:t.parseQuery(o[12]||""),hashString:o[13]||"",hashObject:{},hashPath:[],isInternal:!1};return n.hashString.length>0&&("/"==n.hashString.charAt(0)?n.hashPath=t.parsePath(n.hashString):n.hashObject=t.parseQuery(n.hashString)),""!=n.host?-1==n.host.search(/\.[^\.]+/)&&(n.path="/"+n.host+n.path,n.relative="/"+n.host+n.relative,n.host=window.location.hostname):n.host=window.location.hostname,n.host==window.location.hostname&&(n.isInternal=!0),n.origin=n.protocol+"://"+n.host+(""!=n.port?":"+n.port:""),n.full=n.origin+n.relative,n}},r.ddUrl.current=r.ddUrl.parse(),r((function(){(r.ddTools&&r.ddTools.$window||r(window)).on("popstate",(function(t){r.ddUrl.current=r.ddUrl.parse()}))}))}(jQuery);