diff --git a/vendor/hal-browser/MIT-LICENSE.txt b/vendor/hal-browser/MIT-LICENSE.txt old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/README.adoc b/vendor/hal-browser/README.adoc new file mode 100755 index 000000000..7fc98a717 --- /dev/null +++ b/vendor/hal-browser/README.adoc @@ -0,0 +1,169 @@ += HAL-browser + +An API browser for the hal+json media type + +== Example Usage + +Here is an example of a hal+json API using the browser: + +http://haltalk.herokuapp.com/explorer/browser.html[http://haltalk.herokuapp.com/explorer/browser.html] + +== About HAL + +HAL is a format based on json that establishes conventions for +representing links. For example: + +[source,javascript] +---- +{ + "_links": { + "self": { "href": "/orders" }, + "next": { "href": "/orders?page=2" } + } +} +---- + +More detail about HAL can be found at +http://stateless.co/hal_specification.html[http://stateless.co/hal_specification.html]. + +== Customizing the POST form + +By default, the HAL Browser can't assume there is any metadata. When you click on the non-GET request button (to create a new resource), the user must enter the JSON document to submit. If your service includes metadata you can access, it's possible to plugin a custom view that makes use of it. + +. Define your custom view. ++ +Here is an example that leverages Spring Data REST's JSON Schema metadata found at */{entity}/schema*. ++ +[source,javascript] +---- +var CustomPostForm = Backbone.View.extend({ + initialize: function (opts) { + this.href = opts.href.split('{')[0]; + this.vent = opts.vent; + _.bindAll(this, 'createNewResource'); + }, + + events: { + 'submit form': 'createNewResource' + }, + + className: 'modal fade', + + createNewResource: function (e) { + e.preventDefault(); + + var self = this; + + var data = {} + Object.keys(this.schema.properties).forEach(function(property) { + if (!("format" in self.schema.properties[property])) { + data[property] = self.$('input[name=' + property + ']').val(); + } + }); + + var opts = { + url: this.$('.url').val(), + headers: HAL.parseHeaders(this.$('.headers').val()), + method: this.$('.method').val(), + data: JSON.stringify(data) + }; + + var request = HAL.client.request(opts); + request.done(function (response) { + self.vent.trigger('response', {resource: response, jqxhr: jqxhr}); + }).fail(function (response) { + self.vent.trigger('fail-response', {jqxhr: jqxhr}); + }).always(function () { + self.vent.trigger('response-headers', {jqxhr: jqxhr}); + window.location.hash = 'NON-GET:' + opts.url; + }); + + this.$el.modal('hide'); + }, + + render: function (opts) { + var headers = HAL.client.getHeaders(); + var headersString = ''; + + _.each(headers, function (value, name) { + headersString += name + ': ' + value + '\n'; + }); + + var request = HAL.client.request({ + url: this.href + '/schema', + method: 'GET' + }); + + var self = this; + request.done(function (schema) { + self.schema = schema; + self.$el.html(self.template({ + href: self.href, + schema: self.schema, + user_defined_headers: headersString})); + self.$el.modal(); + }); + + return this; + }, + template: _.template($('#dynamic-request-template').html()) +}); +---- ++ +. Register it by assigning to `HAL.customPostForm` ++ +[source,javascript] +---- +HAL.customPostForm = CustomPostForm; +---- ++ +. Load your custom JavaScript component and define your custom HTML template. ++ +[source,html,indent=0] +---- + +---- + +NOTE: To load a custom JavaScript module AND a custom HTML template, you will probably need to create a customized version of `browser.html`. + +NOTE: The HAL Browser uses a global `HAL` object, so there is no need to deal with JavaScript packages. + +== Usage Instructions + +All you should need to do is copy the files into your webroot. +It is OK to put it in a subdirectory; it does not need to be in the root. + +All the JS and CSS dependencies come included in the vendor directory. + +== TODO + +* Provide feedback to user when there are issues with response (missing +self link, wrong media type identifier) +* Give 'self' and 'curies' links special treatment \ No newline at end of file diff --git a/vendor/hal-browser/README.md b/vendor/hal-browser/README.md deleted file mode 100644 index b0d6faabf..000000000 --- a/vendor/hal-browser/README.md +++ /dev/null @@ -1,41 +0,0 @@ -HAL-browser -=========== -An API browser for the hal+json media type - -Example Usage -============= -Here is an example of a hal+json API using the browser: - -[http://haltalk.herokuapp.com/explorer/browser.html](http://haltalk.herokuapp.com/explorer/browser.html) - -About HAL -======== -HAL is a format based on json that establishes conventions for -representing links. For example: - -```javascript -{ - "_links": { - "self": { "href": "/orders" }, - "next": { "href": "/orders?page=2" } - } -} -``` - -More detail about HAL can be found at -[http://stateless.co/hal_specification.html](http://stateless.co/hal_specification.html). - -Instructions -============ -All you should need to do is copy the files into your webroot. -It is OK to put it in a subdirectory; it does not need to be in the root. - -All the JS and CSS dependencies come included in the vendor directory. - - -TODO -=========== -* Make Location and Content-Location headers clickable links -* Provide feedback to user when there are issues with response (missing -self link, wrong media type identifier) -* Give 'self' and 'curies' links special treatment diff --git a/vendor/hal-browser/browser.html b/vendor/hal-browser/browser.html old mode 100644 new mode 100755 index a907eff2c..a95857d06 --- a/vendor/hal-browser/browser.html +++ b/vendor/hal-browser/browser.html @@ -26,7 +26,7 @@ @@ -38,7 +38,7 @@ - + diff --git a/vendor/hal-browser/js/hal.js b/vendor/hal-browser/js/hal.js old mode 100644 new mode 100755 index 0bbfd5a39..acbd55ec4 --- a/vendor/hal-browser/js/hal.js +++ b/vendor/hal-browser/js/hal.js @@ -1,10 +1,6 @@ (function() { var urlRegex = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; - function isCurie(string) { - return string.split(':').length > 1; - }; - var HAL = { Models: {}, Views: {}, @@ -12,17 +8,43 @@ currentDocument: {}, jsonIndent: 2, isUrl: function(str) { - return str.match(urlRegex) || isCurie(str); + return str.match(urlRegex) || HAL.isCurie(str); + }, + isCurie: function(string) { + var isCurie = false; + var curieParts = string.split(':'); + var curies = HAL.currentDocument._links.curies; + + if(curieParts.length > 1 && curies) { + + for (var i=0; i'); + this.$el.html(''); } }); diff --git a/vendor/hal-browser/js/hal/views/embedded_resource.js b/vendor/hal-browser/js/hal/views/embedded_resource.js old mode 100644 new mode 100755 index ea5fdbe03..8b8187275 --- a/vendor/hal-browser/js/hal/views/embedded_resource.js +++ b/vendor/hal-browser/js/hal/views/embedded_resource.js @@ -22,9 +22,9 @@ HAL.Views.EmbeddedResource = Backbone.View.extend({ onToggleClick: function(e) { e.preventDefault(); this.$accordionBody.collapse('toggle'); + return false; }, - - + onDoxClick: function(e) { e.preventDefault(); this.vent.trigger('show-docs', { @@ -36,16 +36,22 @@ HAL.Views.EmbeddedResource = Backbone.View.extend({ render: function() { this.$el.empty(); - this.linksView.render(this.resource.links); this.propertiesView.render(this.resource.toJSON()); + this.linksView.render(this.resource.links); this.$el.append(this.template({ resource: this.resource })); var $inner = $('
'); - $inner.append(this.linksView.el); $inner.append(this.propertiesView.el); + $inner.append(this.linksView.el); + + if (this.resource.embeddedResources) { + var embeddedResourcesView = new HAL.Views.EmbeddedResources({ vent: this.vent }); + embeddedResourcesView.render(this.resource.embeddedResources); + $inner.append(embeddedResourcesView.el); + } this.$accordionBody = $('
'); this.$accordionBody.append($inner) diff --git a/vendor/hal-browser/js/hal/views/embedded_resources.js b/vendor/hal-browser/js/hal/views/embedded_resources.js old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/js/hal/views/explorer.js b/vendor/hal-browser/js/hal/views/explorer.js old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/js/hal/views/inspector.js b/vendor/hal-browser/js/hal/views/inspector.js old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/js/hal/views/links.js b/vendor/hal-browser/js/hal/views/links.js old mode 100644 new mode 100755 index 512444786..db5596932 --- a/vendor/hal-browser/js/hal/views/links.js +++ b/vendor/hal-browser/js/hal/views/links.js @@ -33,10 +33,11 @@ HAL.Views.Links = Backbone.View.extend({ showNonSafeRequestDialog: function(e) { e.preventDefault(); - var d = new HAL.Views.NonSafeRequestDialog({ + var postForm = (HAL.customPostForm !== undefined) ? HAL.customPostForm : HAL.Views.NonSafeRequestDialog; + var d = new postForm({ href: $(e.currentTarget).attr('href'), vent: this.vent - }).render({}); + }).render({}) }, showDocs: function(e) { diff --git a/vendor/hal-browser/js/hal/views/location_bar.js b/vendor/hal-browser/js/hal/views/location_bar.js old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/js/hal/views/navigation.js b/vendor/hal-browser/js/hal/views/navigation.js old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js b/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js old mode 100644 new mode 100755 index 0b55bdab2..5bc1b66ad --- a/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js +++ b/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js @@ -37,7 +37,7 @@ HAL.Views.NonSafeRequestDialog = Backbone.View.extend({ }, render: function(opts) { - var headers = HAL.client.getDefaultHeaders(), + var headers = HAL.client.getHeaders(), headersString = ''; _.each(headers, function(value, name) { diff --git a/vendor/hal-browser/js/hal/views/properties.js b/vendor/hal-browser/js/hal/views/properties.js old mode 100644 new mode 100755 index f37a0af83..c732b87b9 --- a/vendor/hal-browser/js/hal/views/properties.js +++ b/vendor/hal-browser/js/hal/views/properties.js @@ -5,9 +5,108 @@ HAL.Views.Properties = Backbone.View.extend({ }, className: 'properties', - + + _mkIndent: function(indent, space) { + var s = ""; + for(var i=0; i"; + } + + if(Array.isArray(value)) { + s += '['; + ++indent; + for(var i=0; i + + + + Sign in - HAL Browser + + + + + + + + + +
+ +
+ + diff --git a/vendor/hal-browser/styles.css b/vendor/hal-browser/styles.css old mode 100644 new mode 100755 index 73c88b32d..3f3c9ddbe --- a/vendor/hal-browser/styles.css +++ b/vendor/hal-browser/styles.css @@ -1,3 +1,5 @@ +html, body, #browser, .hal-browser { height: 100%; } + #browser #location-bar { margin: 10px 0; } #browser #location-bar .address { @@ -28,7 +30,7 @@ .documentation { height: 100%; } .documentation iframe { width: 100%; height: 100%; } -.documentation iframe { min-height: 600px } /* Beth: don't know why we need this, it used to display full height without setting a min-height. No idea what changed. */ +.documentation iframe { min-height: 600px } /* pact_broker Beth: don't know why we need this, it used to display full height without setting a min-height. No idea what changed. */ .modal input, .modal textarea { width: 90%; diff --git a/vendor/hal-browser/vendor/css/bootstrap-responsive.css b/vendor/hal-browser/vendor/css/bootstrap-responsive.css old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/vendor/css/bootstrap.css b/vendor/hal-browser/vendor/css/bootstrap.css old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/vendor/img/ajax-loader.gif b/vendor/hal-browser/vendor/img/ajax-loader.gif old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/vendor/img/glyphicons-halflings-white.png b/vendor/hal-browser/vendor/img/glyphicons-halflings-white.png old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/vendor/img/glyphicons-halflings.png b/vendor/hal-browser/vendor/img/glyphicons-halflings.png old mode 100644 new mode 100755 diff --git a/vendor/hal-browser/vendor/js/URI.min.js b/vendor/hal-browser/vendor/js/URI.min.js new file mode 100755 index 000000000..4bb2f5af9 --- /dev/null +++ b/vendor/hal-browser/vendor/js/URI.min.js @@ -0,0 +1,84 @@ +/*! URI.js v1.14.1 http://medialize.github.io/URI.js/ */ +/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */ +(function(f,l){"object"===typeof exports?module.exports=l():"function"===typeof define&&define.amd?define(l):f.IPv6=l(f)})(this,function(f){var l=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var m=g.length,b=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[m-1]&&""===g[m-2]&&g.pop();m=g.length;-1!==g[m-1].indexOf(".")&&(b=7);var k;for(k=0;kf;f++)if("0"===m[0]&&1f&&(m=h,f=l)):"0"===g[k]&&(r=!0,h=k,l=1);l>f&&(m=h,f=l);1=c&&h>>10&1023|55296),b=56320|b&1023);return e+=A(b)}).join("")}function y(b, +e){return b+22+75*(26>b)-((0!=e)<<5)}function p(b,e,h){var a=0;b=h?q(b/700):b>>1;for(b+=q(b/e);455w&&(w=0);for(x=0;x=h&&l("invalid-input");f=b.charCodeAt(w++);f=10>f-48?f-22:26>f-65?f-65:26>f-97?f-97:36;(36<=f||f>q((2147483647-c)/a))&&l("overflow");c+=f*a;m= +g<=t?1:g>=t+26?26:g-t;if(fq(2147483647/f)&&l("overflow");a*=f}a=e.length+1;t=p(c-x,a,0==x);q(c/a)>2147483647-d&&l("overflow");d+=q(c/a);c%=a;e.splice(c++,0,d)}return k(e)}function r(e){var h,g,a,c,d,t,w,x,f,m=[],r,k,n;e=b(e);r=e.length;h=128;g=0;d=72;for(t=0;tf&&m.push(A(f));for((a=c=m.length)&&m.push("-");a=h&&fq((2147483647-g)/k)&&l("overflow");g+=(w-h)*k;h=w;for(t=0;t=d+26?26:w-d;if(x= 0x80 (not a basic code point)", +"invalid-input":"Invalid input"},q=Math.floor,A=String.fromCharCode,D;s={version:"1.2.3",ucs2:{decode:b,encode:k},decode:h,encode:r,toASCII:function(b){return m(b,function(b){return e.test(b)?"xn--"+r(b):b})},toUnicode:function(b){return m(b,function(b){return n.test(b)?h(b.slice(4).toLowerCase()):b})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return s});else if(B&&!B.nodeType)if(C)C.exports=s;else for(D in s)s.hasOwnProperty(D)&&(B[D]=s[D]);else f.punycode= +s})(this); +(function(f,l){"object"===typeof exports?module.exports=l():"function"===typeof define&&define.amd?define(l):f.SecondLevelDomains=l(f)})(this,function(f){var l=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ", +bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ", +cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ", +et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ", +id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ", +kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ", +mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ", +ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ", +ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ", +tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", +rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", +tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", +us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return!1; +var k=f.lastIndexOf(".",b-1);if(0>=k||k>=b-1)return!1;var l=g.list[f.slice(b+1)];return l?0<=l.indexOf(" "+f.slice(k+1,b)+" "):!1},is:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1||0<=f.lastIndexOf(".",b-1))return!1;var k=g.list[f.slice(b+1)];return k?0<=k.indexOf(" "+f.slice(0,b)+" "):!1},get:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return null;var k=f.lastIndexOf(".",b-1);if(0>=k||k>=b-1)return null;var l=g.list[f.slice(b+1)];return!l||0>l.indexOf(" "+f.slice(k+ +1,b)+" ")?null:f.slice(k+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=l);return this}};return g}); +(function(f,l){"object"===typeof exports?module.exports=l(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],l):f.URI=l(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,l,g,m){function b(a,c){if(!(this instanceof b))return new b(a,c);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==c?this.absoluteTo(c):this}function k(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, +"\\$1")}function y(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function p(a){return"Array"===y(a)}function h(a,c){var d,b;if(p(c)){d=0;for(b=c.length;d]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;b.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};b.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};b.invalid_hostname_characters= +/[^a-zA-Z0-9\.-]/;b.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};b.getDomAttribute=function(a){if(a&&a.nodeName){var c=a.nodeName.toLowerCase();return"input"===c&&"image"!==a.type?void 0:b.domAttributes[c]}};b.encode=C;b.decode=decodeURIComponent;b.iso8859=function(){b.encode=escape;b.decode=unescape};b.unicode=function(){b.encode=C;b.decode= +decodeURIComponent};b.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",", +"%3B":";","%3D":"="}}}};b.encodeQuery=function(a,c){var d=b.encode(a+"");void 0===c&&(c=b.escapeQuerySpace);return c?d.replace(/%20/g,"+"):d};b.decodeQuery=function(a,c){a+="";void 0===c&&(c=b.escapeQuerySpace);try{return b.decode(c?a.replace(/\+/g,"%20"):a)}catch(d){return a}};b.recodePath=function(a){a=(a+"").split("/");for(var c=0,d=a.length;cb)return a.charAt(0)===c.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(b)||"/"!==c.charAt(b))b=a.substring(0,b).lastIndexOf("/");return a.substring(0,b+1)};b.withinString=function(a,c,d){d||(d={});var e=d.start||b.findUri.start,f=d.end||b.findUri.end,h=d.trim||b.findUri.trim,g=/[a-z0-9-]=["']?$/i;for(e.lastIndex=0;;){var r=e.exec(a);if(!r)break;r=r.index;if(d.ignoreHtml){var k= +a.slice(Math.max(r-3,0),r);if(k&&g.test(k))continue}var k=r+a.slice(r).search(f),m=a.slice(r,k).replace(h,"");d.ignore&&d.ignore.test(m)||(k=r+m.length,m=c(m,r,k,a),a=a.slice(0,r)+m+a.slice(k),e.lastIndex=r+m.length)}e.lastIndex=0;return a};b.ensureValidHostname=function(a){if(a.match(b.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(b.invalid_hostname_characters))throw new TypeError('Hostname "'+ +a+'" contains characters other than [A-Z0-9.-]');}};b.noConflict=function(a){if(a)return a={URI:this.noConflict()},m.URITemplate&&"function"===typeof m.URITemplate.noConflict&&(a.URITemplate=m.URITemplate.noConflict()),m.IPv6&&"function"===typeof m.IPv6.noConflict&&(a.IPv6=m.IPv6.noConflict()),m.SecondLevelDomains&&"function"===typeof m.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=m.SecondLevelDomains.noConflict()),a;m.URI===this&&(m.URI=n);return this};e.build=function(a){if(!0===a)this._deferred_build= +!0;else if(void 0===a||this._deferred_build)this._string=b.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new b(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};e.protocol=z("protocol");e.username=z("username");e.password=z("password");e.hostname=z("hostname");e.port=z("port");e.query=s("query","?");e.fragment=s("fragment","#");e.search=function(a,c){var d=this.query(a,c);return"string"===typeof d&&d.length?"?"+d:d};e.hash=function(a,c){var d= +this.fragment(a,c);return"string"===typeof d&&d.length?"#"+d:d};e.pathname=function(a,c){if(void 0===a||!0===a){var d=this._parts.path||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}this._parts.path=a?b.recodePath(a):"/";this.build(!c);return this};e.path=e.pathname;e.href=function(a,c){var d;if(void 0===a)return this.toString();this._string="";this._parts=b._parts();var e=a instanceof b,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=b.getDomAttribute(a),a=a[f]|| +"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=b.parse(String(a),this._parts);else if(e||f)for(d in e=e?a._parts:a,e)u.call(this._parts,d)&&(this._parts[d]=e[d]);else throw new TypeError("invalid input");this.build(!c);return this};e.is=function(a){var c=!1,d=!1,e=!1,f=!1,h=!1,r=!1,k=!1,m=!this._parts.urn;this._parts.hostname&&(m=!1,d=b.ip4_expression.test(this._parts.hostname),e=b.ip6_expression.test(this._parts.hostname),c=d||e,h=(f= +!c)&&g&&g.has(this._parts.hostname),r=f&&b.idn_expression.test(this._parts.hostname),k=f&&b.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return m;case "absolute":return!m;case "domain":case "name":return f;case "sld":return h;case "ip":return c;case "ip4":case "ipv4":case "inet4":return d;case "ip6":case "ipv6":case "inet6":return e;case "idn":return r;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return k}return null}; +var D=e.protocol,E=e.port,F=e.hostname;e.protocol=function(a,c){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(b.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return D.call(this,a,c)};e.scheme=e.protocol;e.port=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]'); +return E.call(this,a,c)};e.hostname=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var d={};b.parseHost(a,d);a=d.hostname}return F.call(this,a,c)};e.host=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?b.buildHost(this._parts):"";b.parseHost(a,this._parts);this.build(!c);return this};e.authority=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?b.buildAuthority(this._parts): +"";b.parseAuthority(a,this._parts);this.build(!c);return this};e.userinfo=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var d=b.buildUserinfo(this._parts);return d.substring(0,d.length-1)}"@"!==a[a.length-1]&&(a+="@");b.parseUserinfo(a,this._parts);this.build(!c);return this};e.resource=function(a,c){var d;if(void 0===a)return this.path()+this.search()+this.hash();d=b.parse(a);this._parts.path=d.path;this._parts.query=d.query;this._parts.fragment= +d.fragment;this.build(!c);return this};e.subdomain=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,d)||""}d=this._parts.hostname.length-this.domain().length;d=this._parts.hostname.substring(0,d);d=new RegExp("^"+k(d));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&b.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(d, +a);this.build(!c);return this};e.domain=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.match(/\./g);if(d&&2>d.length)return this._parts.hostname;d=this._parts.hostname.length-this.tld(c).length-1;d=this._parts.hostname.lastIndexOf(".",d-1)+1;return this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");b.ensureValidHostname(a); +!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(d=new RegExp(k(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a));this.build(!c);return this};e.tld=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),d=this._parts.hostname.substring(d+1);return!0!==c&&g&&g.list[d.toLowerCase()]?g.get(this._parts.hostname)||d:d}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&& +g.is(a))d=new RegExp(k(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=new RegExp(k(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(d,a)}else throw new TypeError("cannot set TLD empty");this.build(!c);return this};e.directory=function(a,c){if(this._parts.urn)return void 0=== +a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var d=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0,d)||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}d=this._parts.path.length-this.filename().length;d=this._parts.path.substring(0,d);d=new RegExp("^"+k(d));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=b.recodePath(a);this._parts.path= +this._parts.path.replace(d,a);this.build(!c);return this};e.filename=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(d+1);return a?b.decodePathSegment(d):d}d=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(d=!0);var e=new RegExp(k(this.filename())+"$");a=b.recodePath(a);this._parts.path=this._parts.path.replace(e,a);d?this.normalizePath(c): +this.build(!c);return this};e.suffix=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this.filename(),e=d.lastIndexOf(".");if(-1===e)return"";d=d.substring(e+1);d=/^[a-z0-9%]+$/i.test(d)?d:"";return a?b.decodePathSegment(d):d}"."===a.charAt(0)&&(a=a.substring(1));if(d=this.suffix())e=a?new RegExp(k(d)+"$"):new RegExp(k("."+d)+"$");else{if(!a)return this;this._parts.path+="."+b.recodePath(a)}e&&(a=b.recodePath(a), +this._parts.path=this._parts.path.replace(e,a));this.build(!c);return this};e.segment=function(a,c,d){var b=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(b);void 0!==a&&"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===c)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(p(c)){e=[];a=0;for(var h=c.length;a