This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
/
jsuri-1.1.1.min.js
16 lines (16 loc) · 4.47 KB
/
jsuri-1.1.1.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*!
* jsUri v1.1.1
* https://github.com/derek-watson/jsUri
*
* Copyright 2011, Derek Watson
* Released under the MIT license.
* http://jquery.org/license
*
* Includes parseUri regular expressions
* http://blog.stevenlevithan.com/archives/parseuri
* Copyright 2007, Steven Levithan
* Released under the MIT license.
*
* Date: Mon Nov 14 20:06:34 2011 -0800
*/
var Query=function(b){var e=function(n){var k=[],m,r,o,l;if(typeof(n)==="undefined"||n===null||n===""){return k}if(n.indexOf("?")===0){n=n.substring(1)}r=n.toString().split(/[&;]/);for(m=0;m<r.length;m++){o=r[m];l=o.split("=");k.push([l[0],l[1]])}return k},d=e(b),c=function(){var l="",k,m;for(k=0;k<d.length;k++){m=d[k];if(l.length>0){l+="&"}l+=m.join("=")}return l.length>0?"?"+l:l},a=function(k){k=decodeURIComponent(k);k=k.replace("+"," ");return k},i=function(l){var m,k;for(k=0;k<d.length;k++){m=d[k];if(a(l)===a(m[0])){return m[1]}}},h=function(m){var k=[],l,n;for(l=0;l<d.length;l++){n=d[l];if(a(m)===a(n[0])){k.push(n[1])}}return k},j=function(n,q){var k=[],m,p,l,o;for(m=0;m<d.length;m++){p=d[m];l=a(p[0])===a(n);o=a(p[1])===a(q);if((arguments.length===1&&!l)||(arguments.length===2&&!l&&!o)){k.push(p)}}d=k;return this},f=function(l,m,k){if(arguments.length===3&&k!==-1){k=Math.min(k,d.length);d.splice(k,0,[l,m])}else{if(arguments.length>0){d.push([l,m])}}return this},g=function(o,m,k){var l=-1,n,p;if(arguments.length===3){for(n=0;n<d.length;n++){p=d[n];if(a(p[0])===a(o)&&decodeURIComponent(p[1])===a(k)){l=n;break}}j(o,k).addParam(o,m,l)}else{for(n=0;n<d.length;n++){p=d[n];if(a(p[0])===a(o)){l=n;break}}j(o);f(o,m,l)}return this};return{getParamValue:i,getParamValues:h,deleteParam:j,addParam:f,replaceParam:g,toString:c}};var Uri=function(k){var l=false,x=function(J){var F={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},H=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],I={name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},D=F[l?"strict":"loose"].exec(J),G={},E=14;while(E--){G[H[E]]=D[E]||""}G[I.name]={};G[H[12]].replace(I.parser,function(L,K,M){if(K){G[I.name][K]=M}});return G},j=x(k||""),C=new Query(j.query),o=function(D){if(typeof D!=="undefined"){j.protocol=D}return j.protocol},h=null,b=function(D){if(typeof D!=="undefined"){h=D}if(h===null){return(j.source.indexOf("//")!==-1)}else{return h}},g=function(D){if(typeof D!=="undefined"){j.userInfo=D}return j.userInfo},p=function(D){if(typeof D!=="undefined"){j.host=D}return j.host},m=function(D){if(typeof D!=="undefined"){j.port=D}return j.port},r=function(D){if(typeof D!=="undefined"){j.path=D}return j.path},f=function(D){if(typeof D!=="undefined"){C=new Query(D)}return C},i=function(D){if(typeof D!=="undefined"){j.anchor=D}return j.anchor},w=function(D){o(D);return this},s=function(D){b(D);return this},n=function(D){g(D);return this},y=function(D){p(D);return this},u=function(D){m(D);return this},B=function(D){r(D);return this},t=function(D){f(D);return this},a=function(D){i(D);return this},c=function(D){return f().getParamValue(D)},e=function(D){return f().getParamValues(D)},z=function(D,E){if(arguments.length===2){f().deleteParam(D,E)}else{f().deleteParam(D)}return this},d=function(E,F,D){if(arguments.length===3){f().addParam(E,F,D)}else{f().addParam(E,F)}return this},q=function(F,E,D){if(arguments.length===3){f().replaceParam(F,E,D)}else{f().replaceParam(F,E)}return this},v=function(){var D="",E=function(F){return(F!==null&&F!=="")};if(E(o())){D+=o();if(o().indexOf(":")!==o().length-1){D+=":"}D+="//"}else{if(b()&&E(p())){D+="//"}}if(E(g())&&E(p())){D+=g();if(g().indexOf("@")!==g().length-1){D+="@"}}if(E(p())){D+=p();if(E(m())){D+=":"+m()}}if(E(r())){D+=r()}else{if(E(p())&&(E(f().toString())||E(i()))){D+="/"}}if(E(f().toString())){if(f().toString().indexOf("?")!==0){D+="?"}D+=f().toString()}if(E(i())){if(i().indexOf("#")!==0){D+="#"}D+=i()}return D},A=function(){return new Uri(v())};return{protocol:o,hasAuthorityPrefix:b,userInfo:g,host:p,port:m,path:r,query:f,anchor:i,setProtocol:w,setHasAuthorityPrefix:s,setUserInfo:n,setHost:y,setPort:u,setPath:B,setQuery:t,setAnchor:a,getQueryParamValue:c,getQueryParamValues:e,deleteQueryParam:z,addQueryParam:d,replaceQueryParam:q,toString:v,clone:A}};var jsUri=Uri;