UNPKG

qoopido.nucleus

Version:

Lightweight, atomic and modular JavaScript utility library that strongly encourages the creation and usage of small yet flexible, reusable and easily maintainable modules.

4 lines (3 loc) 2.56 kB
/**! Qoopido.nucleus 3.2.15 | http://nucleus.qoopido.com | (c) 2021 Dirk Lueth */ !function(e,t){"use strict";provide(["/demand/abstract/uuid","/demand/function/iterate"],(function(e,r){var u,i=Object.defineProperties,n={},s=/^\//,a=/[?&]?([^=]+)=([^&]*)/g,o=/%20/g,h=/%5B/g,d=/%5D/g,c=new RegExp("^"+((u=t.createElement("a")).href="/",u.href.slice(0,-1)),"i"),p={"http:":/:80$/,"https:":/:443$/,"ftp:":/:21$/};function l(e,t){var r;if(r=n[e])return r.link[t]}function f(e,t,r){var u;(u=n[e])&&(u.link[t]=r)}function m(e){i(this,{uuid:{value:e}}),m.update(this)}function g(r){var u=e.call(this),s=t.createElement("a");return s.href=r,n[u.uuid]={link:s,parameter:{}},i(u,{toString:{value:function(){return s.toString()}},valueOf:{value:function(){return s.valueOf()}},parameter:{value:new m(u.uuid)}}),u}return m.prototype={get:function(e){return n[this.uuid].parameter[e]},set:function(e,t){n[this.uuid].parameter[e]=t,m.serialize(this)},remove:function(e){delete n[this.uuid].parameter[e],m.serialize(this)}},m.update=function(e){var t,u=n[e.uuid],i=u.parameter,s=u.link.search.split("+").join(" ");for(r(i,(function(e){delete i[e]}));t=a.exec(s);)i[decodeURIComponent(t[1])]=decodeURIComponent(t[2])},m.serialize=function(e){var t=n[e.uuid],u=t.parameter,i="";r(u,(function(e,t){i+=(i?"&":"?")+encodeURIComponent(e)+"="+encodeURIComponent(t)})),t.link.search=i.replace(o,"+").replace(h,"[").replace(d,"]")},g.prototype={get local(){var e;if(e=l(this.uuid,"href"))return c.test(e)},get href(){return l(this.uuid,"href")},set href(e){f(this.uuid,"href",e)},get origin(){var e=this;return l(e.uuid,"origin")||e.protocol+"//"+e.host},get protocol(){return l(this.uuid,"protocol")},set protocol(e){f(this.uuid,"protocol",e)},get username(){return l(this.uuid,"username")},set username(e){f(this.uuid,"username",e)},get password(){return l(this.uuid,"password")},set password(e){f(this.uuid,"password",e)},get host(){var e,t;if(e=l(this.uuid,"host"))return t=l(this.uuid,"protocol"),p[t]?e.replace(p[t],""):e},set host(e){f(this.uuid,"host",e)},get hostname(){return l(this.uuid,"hostname")},set hostname(e){f(this.uuid,"hostname",e)},get port(){return l(this.uuid,"port")},set port(e){f(this.uuid,"port",e)},get pathname(){var e;if(e=l(this.uuid,"pathname"))return s.test(e)?e:"/"+e},set pathname(e){f(this.uuid,"pathname",e)},get search(){return l(this.uuid,"search")},set search(e){f(this.uuid,"search",e),m.update.call(this)},get hash(){return l(this.uuid,"hash")},set hash(e){f(this.uuid,"hash",e)}},g.extends(e)}))}(0,document); //# sourceMappingURL=url.js.map