From 86ede29644ffd2326f9afdbded5cfab79fd523aa Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 18 Feb 2014 18:31:29 +0000 Subject: [PATCH] Removed URI.js, we will use a lighter implementation --- public/js/vendor/uri/IPv6.js | 185 -- public/js/vendor/uri/SecondLevelDomains.js | 220 --- public/js/vendor/uri/URI.fragmentQuery.js | 103 -- public/js/vendor/uri/URI.fragmentURI.js | 96 - public/js/vendor/uri/URI.js | 1938 -------------------- public/js/vendor/uri/URI.min.js | 81 - public/js/vendor/uri/URITemplate.js | 494 ----- public/js/vendor/uri/jquery.URI.js | 232 --- public/js/vendor/uri/jquery.URI.min.js | 7 - public/js/vendor/uri/punycode.js | 508 ----- 10 files changed, 3864 deletions(-) delete mode 100755 public/js/vendor/uri/IPv6.js delete mode 100755 public/js/vendor/uri/SecondLevelDomains.js delete mode 100755 public/js/vendor/uri/URI.fragmentQuery.js delete mode 100755 public/js/vendor/uri/URI.fragmentURI.js delete mode 100755 public/js/vendor/uri/URI.js delete mode 100755 public/js/vendor/uri/URI.min.js delete mode 100755 public/js/vendor/uri/URITemplate.js delete mode 100755 public/js/vendor/uri/jquery.URI.js delete mode 100755 public/js/vendor/uri/jquery.URI.min.js delete mode 100755 public/js/vendor/uri/punycode.js diff --git a/public/js/vendor/uri/IPv6.js b/public/js/vendor/uri/IPv6.js deleted file mode 100755 index 4cb745da5..000000000 --- a/public/js/vendor/uri/IPv6.js +++ /dev/null @@ -1,185 +0,0 @@ -/*! - * URI.js - Mutating URLs - * IPv6 Support - * - * Version: 1.11.2 - * - * Author: Rodney Rehm - * Web: http://medialize.github.com/URI.js/ - * - * Licensed under - * MIT License http://www.opensource.org/licenses/mit-license - * GPL v3 http://opensource.org/licenses/GPL-3.0 - * - */ -(function (root, factory) { - // https://github.com/umdjs/umd/blob/master/returnExports.js - if (typeof exports === 'object') { - // Node - module.exports = factory(); - } else if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(factory); - } else { - // Browser globals (root is window) - root.IPv6 = factory(root); - } -}(this, function (root) { -"use strict"; - -/* -var _in = "fe80:0000:0000:0000:0204:61ff:fe9d:f156"; -var _out = IPv6.best(_in); -var _expected = "fe80::204:61ff:fe9d:f156"; - -console.log(_in, _out, _expected, _out === _expected); -*/ - -// save current IPv6 variable, if any -var _IPv6 = root && root.IPv6; - -function best(address) { - // based on: - // Javascript to test an IPv6 address for proper format, and to - // present the "best text representation" according to IETF Draft RFC at - // http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04 - // 8 Feb 2010 Rich Brown, Dartware, LLC - // Please feel free to use this code as long as you provide a link to - // http://www.intermapper.com - // http://intermapper.com/support/tools/IPV6-Validator.aspx - // http://download.dartware.com/thirdparty/ipv6validator.js - - var _address = address.toLowerCase(); - var segments = _address.split(':'); - var length = segments.length; - var total = 8; - - // trim colons (:: or ::a:b:c… or …a:b:c::) - if (segments[0] === '' && segments[1] === '' && segments[2] === '') { - // must have been :: - // remove first two items - segments.shift(); - segments.shift(); - } else if (segments[0] === '' && segments[1] === '') { - // must have been ::xxxx - // remove the first item - segments.shift(); - } else if (segments[length - 1] === '' && segments[length - 2] === '') { - // must have been xxxx:: - segments.pop(); - } - - length = segments.length; - - // adjust total segments for IPv4 trailer - if (segments[length - 1].indexOf('.') !== -1) { - // found a "." which means IPv4 - total = 7; - } - - // fill empty segments them with "0000" - var pos; - for (pos = 0; pos < length; pos++) { - if (segments[pos] === '') { - break; - } - } - - if (pos < total) { - segments.splice(pos, 1, '0000'); - while (segments.length < total) { - segments.splice(pos, 0, '0000'); - } - - length = segments.length; - } - - // strip leading zeros - var _segments; - for (var i = 0; i < total; i++) { - _segments = segments[i].split(""); - for (var j = 0; j < 3 ; j++) { - if (_segments[0] === '0' && _segments.length > 1) { - _segments.splice(0,1); - } else { - break; - } - } - - segments[i] = _segments.join(""); - } - - // find longest sequence of zeroes and coalesce them into one segment - var best = -1; - var _best = 0; - var _current = 0; - var current = -1; - var inzeroes = false; - // i; already declared - - for (i = 0; i < total; i++) { - if (inzeroes) { - if (segments[i] === '0') { - _current += 1; - } else { - inzeroes = false; - if (_current > _best) { - best = current; - _best = _current; - } - } - } else { - if (segments[i] == '0') { - inzeroes = true; - current = i; - _current = 1; - } - } - } - - if (_current > _best) { - best = current; - _best = _current; - } - - if (_best > 1) { - segments.splice(best, _best, ""); - } - - length = segments.length; - - // assemble remaining segments - var result = ''; - if (segments[0] === '') { - beststr = ":"; - } - - for (i = 0; i < length; i++) { - result += segments[i]; - if (i === length - 1) { - break; - } - - result += ':'; - } - - if (segments[length - 1] === '') { - result += ":"; - } - - return result; -}; - -function noConflict(){ - if (root.IPv6 === this) { - root.IPv6 = _IPv6; - } - - return this; -}; - -return { - best: best, - noConflict: noConflict -}; -})); diff --git a/public/js/vendor/uri/SecondLevelDomains.js b/public/js/vendor/uri/SecondLevelDomains.js deleted file mode 100755 index 1e28c3111..000000000 --- a/public/js/vendor/uri/SecondLevelDomains.js +++ /dev/null @@ -1,220 +0,0 @@ -/*! - * URI.js - Mutating URLs - * Second Level Domain (SLD) Support - * - * Version: 1.11.2 - * - * Author: Rodney Rehm - * Web: http://medialize.github.com/URI.js/ - * - * Licensed under - * MIT License http://www.opensource.org/licenses/mit-license - * GPL v3 http://opensource.org/licenses/GPL-3.0 - * - */ - -(function (root, factory) { - // https://github.com/umdjs/umd/blob/master/returnExports.js - if (typeof exports === 'object') { - // Node - module.exports = factory(); - } else if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(factory); - } else { - // Browser globals (root is window) - root.SecondLevelDomains = factory(root); - } -}(this, function (root) { -"use strict"; - -// save current SecondLevelDomains variable, if any -var _SecondLevelDomains = root && root.SecondLevelDomains; - -var hasOwn = Object.prototype.hasOwnProperty; -var SLD = { - // list of known Second Level Domains - // converted list of SLDs from https://github.com/gavingmiller/second-level-domains - // ---- - // publicsuffix.org is more current and actually used by a couple of browsers internally. - // downside is it also contains domains like "dyndns.org" - which is fine for the security - // issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js - // ---- - 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", - "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" - }, - // SLD expression for each TLD - //expressions: {}, - // SLD expression for all TLDs - has_expression: null, - is_expression: null, - // validate domain is a known SLD - has: function(domain) { - return !!domain.match(SLD.has_expression); - }, - is: function(domain) { - return !!domain.match(SLD.is_expression); - }, - get: function(domain) { - var t = domain.match(SLD.has_expression); - return t && t[1] || null; - }, - noConflict: function(){ - if (root.SecondLevelDomains === this) { - root.SecondLevelDomains = _SecondLevelDomains; - } - return this; - }, - init: function() { - var t = ''; - for (var tld in SLD.list) { - if (!hasOwn.call(SLD.list, tld)) { - continue; - } - - var expression = '(' + SLD.list[tld] + ')\.' + tld; - //SLD.expressions[tld] = new RegExp('\.' + expression + '$', 'i'); - t += '|(' + expression + ')'; - } - - SLD.has_expression = new RegExp('\\.(' + t.substr(1) + ')$', 'i'); - SLD.is_expression = new RegExp('^(' + t.substr(1) + ')$', 'i'); - } -}; - -SLD.init(); - -return SLD; -})); diff --git a/public/js/vendor/uri/URI.fragmentQuery.js b/public/js/vendor/uri/URI.fragmentQuery.js deleted file mode 100755 index f40554522..000000000 --- a/public/js/vendor/uri/URI.fragmentQuery.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Extending URI.js for fragment abuse - */ - -// -------------------------------------------------------------------------------- -// EXAMPLE: storing application/x-www-form-urlencoded data in the fragment -// possibly helpful for Google's hashbangs -// see http://code.google.com/web/ajaxcrawling/ -// -------------------------------------------------------------------------------- - -// Note: make sure this is the last file loaded! - -// USAGE: -// var uri = URI("http://example.org/#?foo=bar"); -// uri.fragment(true) === {foo: "bar"}; -// uri.fragment({bar: "foo"}); -// uri.toString() === "http://example.org/#?bar=foo"; -// uri.addFragment("name", "value"); -// uri.toString() === "http://example.org/#?bar=foo&name=value"; -// uri.removeFragment("name"); -// uri.toString() === "http://example.org/#?bar=foo"; - -(function (root, factory) { - // https://github.com/umdjs/umd/blob/master/returnExports.js - if (typeof exports === 'object') { - // Node - module.exports = factory(require('./URI')); - } else if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['./URI'], factory); - } else { - // Browser globals (root is window) - factory(root.URI); - } -}(this, function (URI) { -"use strict"; - -var p = URI.prototype; -// old fragment handler we need to wrap -var f = p.fragment; - -// make fragmentPrefix configurable -URI.fragmentPrefix = '?'; -var _parts = URI._parts; -URI._parts = function() { - var parts = _parts(); - parts.fragmentPrefix = URI.fragmentPrefix; - return parts; -}; -p.fragmentPrefix = function(v) { - this._parts.fragmentPrefix = v; - return this; -}; - -// add fragment(true) and fragment({key: value}) signatures -p.fragment = function(v, build) { - var prefix = this._parts.fragmentPrefix; - var fragment = this._parts.fragment || ""; - - if (v === true) { - if (fragment.substring(0, prefix.length) !== prefix) { - return {}; - } - - return URI.parseQuery(fragment.substring(prefix.length)); - } else if (v !== undefined && typeof v !== "string") { - this._parts.fragment = prefix + URI.buildQuery(v); - this.build(!build); - return this; - } else { - return f.call(this, v, build); - } -}; -p.addFragment = function(name, value, build) { - var prefix = this._parts.fragmentPrefix; - var data = URI.parseQuery((this._parts.fragment || "").substring(prefix.length)); - URI.addQuery(data, name, value); - this._parts.fragment = prefix + URI.buildQuery(data); - if (typeof name !== "string") { - build = value; - } - - this.build(!build); - return this; -}; -p.removeFragment = function(name, value, build) { - var prefix = this._parts.fragmentPrefix; - var data = URI.parseQuery((this._parts.fragment || "").substring(prefix.length)); - URI.removeQuery(data, name, value); - this._parts.fragment = prefix + URI.buildQuery(data); - if (typeof name !== "string") { - build = value; - } - - this.build(!build); - return this; -}; -p.addHash = p.addFragment; -p.removeHash = p.removeFragment; - -// extending existing object rather than defining something new -return {}; -})); \ No newline at end of file diff --git a/public/js/vendor/uri/URI.fragmentURI.js b/public/js/vendor/uri/URI.fragmentURI.js deleted file mode 100755 index 3173435d0..000000000 --- a/public/js/vendor/uri/URI.fragmentURI.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Extending URI.js for fragment abuse - */ - -// -------------------------------------------------------------------------------- -// EXAMPLE: storing a relative URL in the fragment ("FragmentURI") -// possibly helpful when working with backbone.js or sammy.js -// inspired by https://github.com/medialize/URI.js/pull/2 -// -------------------------------------------------------------------------------- - -// Note: make sure this is the last file loaded! - -// USAGE: -// var uri = URI("http://example.org/#!/foo/bar/baz.html"); -// var furi = uri.fragment(true); -// furi.pathname() === '/foo/bar/baz.html'; -// furi.pathname('/hello.html'); -// uri.toString() === "http://example.org/#!/hello.html" - -(function (root, factory) { - // https://github.com/umdjs/umd/blob/master/returnExports.js - if (typeof exports === 'object') { - // Node - module.exports = factory(require('./URI')); - } else if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['./URI'], factory); - } else { - // Browser globals (root is window) - factory(root.URI); - } -}(this, function (URI) { -"use strict"; - -var p = URI.prototype; -// old handlers we need to wrap -var f = p.fragment; -var b = p.build; - -// make fragmentPrefix configurable -URI.fragmentPrefix = '!'; -var _parts = URI._parts; -URI._parts = function() { - var parts = _parts(); - parts.fragmentPrefix = URI.fragmentPrefix; - return parts; -}; -p.fragmentPrefix = function(v) { - this._parts.fragmentPrefix = v; - return this; -}; - -// add fragment(true) and fragment(URI) signatures -p.fragment = function(v, build) { - var prefix = this._parts.fragmentPrefix; - var fragment = this._parts.fragment || ""; - var furi; - - if (v === true) { - if (fragment.substring(0, prefix.length) !== prefix) { - furi = URI(""); - } else { - furi = new URI(fragment.substring(prefix.length)); - } - - this._fragmentURI = furi; - furi._parentURI = this; - return furi; - } else if (v !== undefined && typeof v !== "string") { - this._fragmentURI = v; - v._parentURI = v; - this._parts.fragment = prefix + v.toString(); - this.build(!build); - return this; - } else if (typeof v === "string") { - this._fragmentURI = undefined; - } - - return f.call(this, v, build); -}; - -// make .build() of the actual URI aware of the FragmentURI -p.build = function(deferBuild) { - var t = b.call(this, deferBuild); - - if (deferBuild !== false && this._parentURI) { - // update the parent - this._parentURI.fragment(this); - } - - return t; -}; - -// extending existing object rather than defining something new -return {}; -})); \ No newline at end of file diff --git a/public/js/vendor/uri/URI.js b/public/js/vendor/uri/URI.js deleted file mode 100755 index 21a0056bc..000000000 --- a/public/js/vendor/uri/URI.js +++ /dev/null @@ -1,1938 +0,0 @@ -/*! - * URI.js - Mutating URLs - * - * Version: 1.11.2 - * - * Author: Rodney Rehm - * Web: http://medialize.github.com/URI.js/ - * - * Licensed under - * MIT License http://www.opensource.org/licenses/mit-license - * GPL v3 http://opensource.org/licenses/GPL-3.0 - * - */ -(function (root, factory) { - // https://github.com/umdjs/umd/blob/master/returnExports.js - if (typeof exports === 'object') { - // Node - module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains')); - } else if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['./punycode', './IPv6', './SecondLevelDomains'], factory); - } else { - // Browser globals (root is window) - root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root); - } -}(this, function (punycode, IPv6, SLD, root) { -"use strict"; - -// save current URI variable, if any -var _URI = root && root.URI; - -function URI(url, base) { - // Allow instantiation without the 'new' keyword - if (!(this instanceof URI)) { - return new URI(url, base); - } - - if (url === undefined) { - if (typeof location !== 'undefined') { - url = location.href + ""; - } else { - url = ""; - } - } - - this.href(url); - - // resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor - if (base !== undefined) { - return this.absoluteTo(base); - } - - return this; -}; - -var p = URI.prototype; -var hasOwn = Object.prototype.hasOwnProperty; - -function escapeRegEx(string) { - // https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963 - return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -} - -function getType(value) { - // IE8 doesn't return [Object Undefined] but [Object Object] for undefined value - if (value === undefined) { - return 'Undefined'; - } - - return String(Object.prototype.toString.call(value)).slice(8, -1); -} - -function isArray(obj) { - return getType(obj) === "Array"; -} - -function filterArrayValues(data, value) { - var lookup = {}; - var i, length; - - if (isArray(value)) { - for (i = 0, length = value.length; i < length; i++) { - lookup[value[i]] = true; - } - } else { - lookup[value] = true; - } - - for (i = 0, length = data.length; i < length; i++) { - if (lookup[data[i]] !== undefined) { - data.splice(i, 1); - length--; - i--; - } - } - - return data; -} - -function arrayContains(list, value) { - var i, length; - - // value may be string, number, array, regexp - if (isArray(value)) { - // Note: this can be optimized to O(n) (instead of current O(m * n)) - for (i = 0, length = value.length; i < length; i++) { - if (!arrayContains(list, value[i])) { - return false; - } - } - - return true; - } - - var _type = getType(value); - for (i = 0, length = list.length; i < length; i++) { - if (_type === 'RegExp') { - if (typeof list[i] === 'string' && list[i].match(value)) { - return true; - } - } else if (list[i] === value) { - return true; - } - } - - return false; -} - -function arraysEqual(one, two) { - if (!isArray(one) || !isArray(two)) { - return false; - } - - // arrays can't be equal if they have different amount of content - if (one.length !== two.length) { - return false; - } - - one.sort(); - two.sort(); - - for (var i = 0, l = one.length; i < l; i++) { - if (one[i] !== two[i]) { - return false; - } - } - - return true; -} - -URI._parts = function() { - return { - protocol: null, - username: null, - password: null, - hostname: null, - urn: null, - port: null, - path: null, - query: null, - fragment: null, - // state - duplicateQueryParameters: URI.duplicateQueryParameters, - escapeQuerySpace: URI.escapeQuerySpace - }; -}; -// state: allow duplicate query parameters (a=1&a=1) -URI.duplicateQueryParameters = false; -// state: replaces + with %20 (space in query strings) -URI.escapeQuerySpace = true; -// static properties -URI.protocol_expression = /^[a-z][a-z0-9-+-]*$/i; -URI.idn_expression = /[^a-z0-9\.-]/i; -URI.punycode_expression = /(xn--)/i; -// well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care? -URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; -// credits to Rich Brown -// source: http://forums.intermapper.com/viewtopic.php?p=1096#1096 -// specification: http://www.ietf.org/rfc/rfc4291.txt -URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; -// gruber revised expression - http://rodneyrehm.de/t/url-regex.html -URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig; -// http://www.iana.org/assignments/uri-schemes.html -// http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports -URI.defaultPorts = { - http: "80", - https: "443", - ftp: "21", - gopher: "70", - ws: "80", - wss: "443" -}; -// allowed hostname characters according to RFC 3986 -// ALPHA DIGIT "-" "." "_" "~" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" %encoded -// I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . - -URI.invalid_hostname_characters = /[^a-zA-Z0-9\.-]/; -// map DOM Elements to their URI attribute -URI.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' // but only if type="image" -}; -URI.getDomAttribute = function(node) { - if (!node || !node.nodeName) { - return undefined; - } - - var nodeName = node.nodeName.toLowerCase(); - // should only expose src for type="image" - if (nodeName === 'input' && node.type !== 'image') { - return undefined; - } - - return URI.domAttributes[nodeName]; -}; - -function escapeForDumbFirefox36(value) { - // https://github.com/medialize/URI.js/issues/91 - return escape(value); -} - -// encoding / decoding according to RFC3986 -function strictEncodeURIComponent(string) { - // see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent - return encodeURIComponent(string) - .replace(/[!'()*]/g, escapeForDumbFirefox36) - .replace(/\*/g, "%2A"); -} -URI.encode = strictEncodeURIComponent; -URI.decode = decodeURIComponent; -URI.iso8859 = function() { - URI.encode = escape; - URI.decode = unescape; -}; -URI.unicode = function() { - URI.encode = strictEncodeURIComponent; - URI.decode = decodeURIComponent; -}; -URI.characters = { - pathname: { - encode: { - // RFC3986 2.1: For consistency, URI producers and normalizers should - // use uppercase hexadecimal digits for all percent-encodings. - 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: { - // RFC3986 2.1: For consistency, URI producers and normalizers should - // use uppercase hexadecimal digits for all percent-encodings. - expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig, - map: { - // gen-delims - "%3A": ":", - "%2F": "/", - "%3F": "?", - "%23": "#", - "%5B": "[", - "%5D": "]", - "%40": "@", - // sub-delims - "%21": "!", - "%24": "$", - "%26": "&", - "%27": "'", - "%28": "(", - "%29": ")", - "%2A": "*", - "%2B": "+", - "%2C": ",", - "%3B": ";", - "%3D": "=" - } - } - } -}; -URI.encodeQuery = function(string, escapeQuerySpace) { - var escaped = URI.encode(string + ""); - return escapeQuerySpace ? escaped.replace(/%20/g, '+') : escaped; -}; -URI.decodeQuery = function(string, escapeQuerySpace) { - string += ""; - try { - return URI.decode(escapeQuerySpace ? string.replace(/\+/g, '%20') : string); - } catch(e) { - // we're not going to mess with weird encodings, - // give up and return the undecoded original string - // see https://github.com/medialize/URI.js/issues/87 - // see https://github.com/medialize/URI.js/issues/92 - return string; - } -}; -URI.recodePath = function(string) { - var segments = (string + "").split('/'); - for (var i = 0, length = segments.length; i < length; i++) { - segments[i] = URI.encodePathSegment(URI.decode(segments[i])); - } - - return segments.join('/'); -}; -URI.decodePath = function(string) { - var segments = (string + "").split('/'); - for (var i = 0, length = segments.length; i < length; i++) { - segments[i] = URI.decodePathSegment(segments[i]); - } - - return segments.join('/'); -}; -// generate encode/decode path functions -var _parts = {'encode':'encode', 'decode':'decode'}; -var _part; -var generateAccessor = function(_group, _part) { - return function(string) { - return URI[_part](string + "").replace(URI.characters[_group][_part].expression, function(c) { - return URI.characters[_group][_part].map[c]; - }); - }; -}; - -for (_part in _parts) { - URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]); -} - -URI.encodeReserved = generateAccessor("reserved", "encode"); - -URI.parse = function(string, parts) { - var pos; - if (!parts) { - parts = {}; - } - // [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment] - - // extract fragment - pos = string.indexOf('#'); - if (pos > -1) { - // escaping? - parts.fragment = string.substring(pos + 1) || null; - string = string.substring(0, pos); - } - - // extract query - pos = string.indexOf('?'); - if (pos > -1) { - // escaping? - parts.query = string.substring(pos + 1) || null; - string = string.substring(0, pos); - } - - // extract protocol - if (string.substring(0, 2) === '//') { - // relative-scheme - parts.protocol = null; - string = string.substring(2); - // extract "user:pass@host:port" - string = URI.parseAuthority(string, parts); - } else { - pos = string.indexOf(':'); - if (pos > -1) { - parts.protocol = string.substring(0, pos) || null; - if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) { - // : may be within the path - parts.protocol = undefined; - } else if (parts.protocol === 'file') { - // the file scheme: does not contain an authority - string = string.substring(pos + 3); - } else if (string.substring(pos + 1, pos + 3) === '//') { - string = string.substring(pos + 3); - - // extract "user:pass@host:port" - string = URI.parseAuthority(string, parts); - } else { - string = string.substring(pos + 1); - parts.urn = true; - } - } - } - - // what's left must be the path - parts.path = string; - - // and we're done - return parts; -}; -URI.parseHost = function(string, parts) { - // extract host:port - var pos = string.indexOf('/'); - var bracketPos; - var t; - - if (pos === -1) { - pos = string.length; - } - - if (string.charAt(0) === "[") { - // IPv6 host - http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04#section-6 - // I claim most client software breaks on IPv6 anyways. To simplify things, URI only accepts - // IPv6+port in the format [2001:db8::1]:80 (for the time being) - bracketPos = string.indexOf(']'); - parts.hostname = string.substring(1, bracketPos) || null; - parts.port = string.substring(bracketPos+2, pos) || null; - } else if (string.indexOf(':') !== string.lastIndexOf(':')) { - // IPv6 host contains multiple colons - but no port - // this notation is actually not allowed by RFC 3986, but we're a liberal parser - parts.hostname = string.substring(0, pos) || null; - parts.port = null; - } else { - t = string.substring(0, pos).split(':'); - parts.hostname = t[0] || null; - parts.port = t[1] || null; - } - - if (parts.hostname && string.substring(pos).charAt(0) !== '/') { - pos++; - string = "/" + string; - } - - return string.substring(pos) || '/'; -}; -URI.parseAuthority = function(string, parts) { - string = URI.parseUserinfo(string, parts); - return URI.parseHost(string, parts); -}; -URI.parseUserinfo = function(string, parts) { - // extract username:password - var firstSlash = string.indexOf('/'); - var pos = firstSlash > -1 - ? string.lastIndexOf('@', firstSlash) - : string.indexOf('@'); - var t; - - // authority@ must come before /path - if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) { - t = string.substring(0, pos).split(':'); - parts.username = t[0] ? URI.decode(t[0]) : null; - t.shift(); - parts.password = t[0] ? URI.decode(t.join(':')) : null; - string = string.substring(pos + 1); - } else { - parts.username = null; - parts.password = null; - } - - return string; -}; -URI.parseQuery = function(string, escapeQuerySpace) { - if (!string) { - return {}; - } - - // throw out the funky business - "?"[name"="value"&"]+ - string = string.replace(/&+/g, '&').replace(/^\?*&*|&+$/g, ''); - - if (!string) { - return {}; - } - - var items = {}; - var splits = string.split('&'); - var length = splits.length; - var v, name, value; - - for (var i = 0; i < length; i++) { - v = splits[i].split('='); - name = URI.decodeQuery(v.shift(), escapeQuerySpace); - // no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters - value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null; - - if (items[name]) { - if (typeof items[name] === "string") { - items[name] = [items[name]]; - } - - items[name].push(value); - } else { - items[name] = value; - } - } - - return items; -}; - -URI.build = function(parts) { - var t = ""; - - if (parts.protocol) { - t += parts.protocol + ":"; - } - - if (!parts.urn && (t || parts.hostname)) { - t += '//'; - } - - t += (URI.buildAuthority(parts) || ''); - - if (typeof parts.path === "string") { - if (parts.path.charAt(0) !== '/' && typeof parts.hostname === "string") { - t += '/'; - } - - t += parts.path; - } - - if (typeof parts.query === "string" && parts.query) { - t += '?' + parts.query; - } - - if (typeof parts.fragment === "string" && parts.fragment) { - t += '#' + parts.fragment; - } - return t; -}; -URI.buildHost = function(parts) { - var t = ""; - - if (!parts.hostname) { - return ""; - } else if (URI.ip6_expression.test(parts.hostname)) { - if (parts.port) { - t += "[" + parts.hostname + "]:" + parts.port; - } else { - // don't know if we should always wrap IPv6 in [] - // the RFC explicitly says SHOULD, not MUST. - t += parts.hostname; - } - } else { - t += parts.hostname; - if (parts.port) { - t += ':' + parts.port; - } - } - - return t; -}; -URI.buildAuthority = function(parts) { - return URI.buildUserinfo(parts) + URI.buildHost(parts); -}; -URI.buildUserinfo = function(parts) { - var t = ""; - - if (parts.username) { - t += URI.encode(parts.username); - - if (parts.password) { - t += ':' + URI.encode(parts.password); - } - - t += "@"; - } - - return t; -}; -URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) { - // according to http://tools.ietf.org/html/rfc3986 or http://labs.apache.org/webarch/uri/rfc/rfc3986.html - // being »-._~!$&'()*+,;=:@/?« %HEX and alnum are allowed - // the RFC explicitly states ?/foo being a valid use case, no mention of parameter syntax! - // URI.js treats the query string as being application/x-www-form-urlencoded - // see http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type - - var t = ""; - var unique, key, i, length; - for (key in data) { - if (hasOwn.call(data, key) && key) { - if (isArray(data[key])) { - unique = {}; - for (i = 0, length = data[key].length; i < length; i++) { - if (data[key][i] !== undefined && unique[data[key][i] + ""] === undefined) { - t += "&" + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace); - if (duplicateQueryParameters !== true) { - unique[data[key][i] + ""] = true; - } - } - } - } else if (data[key] !== undefined) { - t += '&' + URI.buildQueryParameter(key, data[key], escapeQuerySpace); - } - } - } - - return t.substring(1); -}; -URI.buildQueryParameter = function(name, value, escapeQuerySpace) { - // http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type -- application/x-www-form-urlencoded - // don't append "=" for null values, according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization - return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? "=" + URI.encodeQuery(value, escapeQuerySpace) : ""); -}; - -URI.addQuery = function(data, name, value) { - if (typeof name === "object") { - for (var key in name) { - if (hasOwn.call(name, key)) { - URI.addQuery(data, key, name[key]); - } - } - } else if (typeof name === "string") { - if (data[name] === undefined) { - data[name] = value; - return; - } else if (typeof data[name] === "string") { - data[name] = [data[name]]; - } - - if (!isArray(value)) { - value = [value]; - } - - data[name] = data[name].concat(value); - } else { - throw new TypeError("URI.addQuery() accepts an object, string as the name parameter"); - } -}; -URI.removeQuery = function(data, name, value) { - var i, length, key; - - if (isArray(name)) { - for (i = 0, length = name.length; i < length; i++) { - data[name[i]] = undefined; - } - } else if (typeof name === "object") { - for (key in name) { - if (hasOwn.call(name, key)) { - URI.removeQuery(data, key, name[key]); - } - } - } else if (typeof name === "string") { - if (value !== undefined) { - if (data[name] === value) { - data[name] = undefined; - } else if (isArray(data[name])) { - data[name] = filterArrayValues(data[name], value); - } - } else { - data[name] = undefined; - } - } else { - throw new TypeError("URI.addQuery() accepts an object, string as the first parameter"); - } -}; -URI.hasQuery = function(data, name, value, withinArray) { - if (typeof name === "object") { - for (var key in name) { - if (hasOwn.call(name, key)) { - if (!URI.hasQuery(data, key, name[key])) { - return false; - } - } - } - - return true; - } else if (typeof name !== "string") { - throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter"); - } - - switch (getType(value)) { - case 'Undefined': - // true if exists (but may be empty) - return name in data; // data[name] !== undefined; - - case 'Boolean': - // true if exists and non-empty - var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]); - return value === _booly; - - case 'Function': - // allow complex comparison - return !!value(data[name], name, data); - - case 'Array': - if (!isArray(data[name])) { - return false; - } - - var op = withinArray ? arrayContains : arraysEqual; - return op(data[name], value); - - case 'RegExp': - if (!isArray(data[name])) { - return Boolean(data[name] && data[name].match(value)); - } - - if (!withinArray) { - return false; - } - - return arrayContains(data[name], value); - - case 'Number': - value = String(value); - // omit break; - case 'String': - if (!isArray(data[name])) { - return data[name] === value; - } - - if (!withinArray) { - return false; - } - - return arrayContains(data[name], value); - - default: - throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter"); - } -}; - - -URI.commonPath = function(one, two) { - var length = Math.min(one.length, two.length); - var pos; - - // find first non-matching character - for (pos = 0; pos < length; pos++) { - if (one.charAt(pos) !== two.charAt(pos)) { - pos--; - break; - } - } - - if (pos < 1) { - return one.charAt(0) === two.charAt(0) && one.charAt(0) === '/' ? '/' : ''; - } - - // revert to last / - if (one.charAt(pos) !== '/' || two.charAt(pos) !== '/') { - pos = one.substring(0, pos).lastIndexOf('/'); - } - - return one.substring(0, pos + 1); -}; - -URI.withinString = function(string, callback) { - // expression used is "gruber revised" (@gruber v2) determined to be the best solution in - // a regex sprint we did a couple of ages ago at - // * http://mathiasbynens.be/demo/url-regex - // * http://rodneyrehm.de/t/url-regex.html - - return string.replace(URI.find_uri_expression, callback); -}; - -URI.ensureValidHostname = function(v) { - // Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986) - // they are not part of DNS and therefore ignored by URI.js - - if (v.match(URI.invalid_hostname_characters)) { - // test punycode - if (!punycode) { - throw new TypeError("Hostname '" + v + "' contains characters other than [A-Z0-9.-] and Punycode.js is not available"); - } - - if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) { - throw new TypeError("Hostname '" + v + "' contains characters other than [A-Z0-9.-]"); - } - } -}; - -// noConflict -URI.noConflict = function(removeAll) { - if (removeAll) { - var unconflicted = { - URI: this.noConflict() - }; - - if (URITemplate && typeof URITemplate.noConflict == "function") { - unconflicted.URITemplate = URITemplate.noConflict(); - } - - if (IPv6 && typeof IPv6.noConflict == "function") { - unconflicted.IPv6 = IPv6.noConflict(); - } - - if (SecondLevelDomains && typeof SecondLevelDomains.noConflict == "function") { - unconflicted.SecondLevelDomains = SecondLevelDomains.noConflict(); - } - - return unconflicted; - } else if (root.URI === this) { - root.URI = _URI; - } - - return this; -}; - -p.build = function(deferBuild) { - if (deferBuild === true) { - this._deferred_build = true; - } else if (deferBuild === undefined || this._deferred_build) { - this._string = URI.build(this._parts); - this._deferred_build = false; - } - - return this; -}; - -p.clone = function() { - return new URI(this); -}; - -p.valueOf = p.toString = function() { - return this.build(false)._string; -}; - -// generate simple accessors -_parts = {protocol: 'protocol', username: 'username', password: 'password', hostname: 'hostname', port: 'port'}; -generateAccessor = function(_part){ - return function(v, build) { - if (v === undefined) { - return this._parts[_part] || ""; - } else { - this._parts[_part] = v || null; - this.build(!build); - return this; - } - }; -}; - -for (_part in _parts) { - p[_part] = generateAccessor(_parts[_part]); -} - -// generate accessors with optionally prefixed input -_parts = {query: '?', fragment: '#'}; -generateAccessor = function(_part, _key){ - return function(v, build) { - if (v === undefined) { - return this._parts[_part] || ""; - } else { - if (v !== null) { - v = v + ""; - if (v.charAt(0) === _key) { - v = v.substring(1); - } - } - - this._parts[_part] = v; - this.build(!build); - return this; - } - }; -}; - -for (_part in _parts) { - p[_part] = generateAccessor(_part, _parts[_part]); -} - -// generate accessors with prefixed output -_parts = {search: ['?', 'query'], hash: ['#', 'fragment']}; -generateAccessor = function(_part, _key){ - return function(v, build) { - var t = this[_part](v, build); - return typeof t === "string" && t.length ? (_key + t) : t; - }; -}; - -for (_part in _parts) { - p[_part] = generateAccessor(_parts[_part][1], _parts[_part][0]); -} - -p.pathname = function(v, build) { - if (v === undefined || v === true) { - var res = this._parts.path || (this._parts.hostname ? '/' : ''); - return v ? URI.decodePath(res) : res; - } else { - this._parts.path = v ? URI.recodePath(v) : "/"; - this.build(!build); - return this; - } -}; -p.path = p.pathname; -p.href = function(href, build) { - var key; - - if (href === undefined) { - return this.toString(); - } - - this._string = ""; - this._parts = URI._parts(); - - var _URI = href instanceof URI; - var _object = typeof href === "object" && (href.hostname || href.path || href.pathname); - if (href.nodeName) { - var attribute = URI.getDomAttribute(href); - href = href[attribute] || ""; - _object = false; - } - - // window.location is reported to be an object, but it's not the sort - // of object we're looking for: - // * location.protocol ends with a colon - // * location.query != object.search - // * location.hash != object.fragment - // simply serializing the unknown object should do the trick - // (for location, not for everything...) - if (!_URI && _object && href.pathname !== undefined) { - href = href.toString(); - } - - if (typeof href === "string") { - this._parts = URI.parse(href, this._parts); - } else if (_URI || _object) { - var src = _URI ? href._parts : href; - for (key in src) { - if (hasOwn.call(this._parts, key)) { - this._parts[key] = src[key]; - } - } - } else { - throw new TypeError("invalid input"); - } - - this.build(!build); - return this; -}; - -// identification accessors -p.is = function(what) { - var ip = false; - var ip4 = false; - var ip6 = false; - var name = false; - var sld = false; - var idn = false; - var punycode = false; - var relative = !this._parts.urn; - - if (this._parts.hostname) { - relative = false; - ip4 = URI.ip4_expression.test(this._parts.hostname); - ip6 = URI.ip6_expression.test(this._parts.hostname); - ip = ip4 || ip6; - name = !ip; - sld = name && SLD && SLD.has(this._parts.hostname); - idn = name && URI.idn_expression.test(this._parts.hostname); - punycode = name && URI.punycode_expression.test(this._parts.hostname); - } - - switch (what.toLowerCase()) { - case 'relative': - return relative; - - case 'absolute': - return !relative; - - // hostname identification - case 'domain': - case 'name': - return name; - - case 'sld': - return sld; - - case 'ip': - return ip; - - case 'ip4': - case 'ipv4': - case 'inet4': - return ip4; - - case 'ip6': - case 'ipv6': - case 'inet6': - return ip6; - - case 'idn': - return idn; - - case 'url': - return !this._parts.urn; - - case 'urn': - return !!this._parts.urn; - - case 'punycode': - return punycode; - } - - return null; -}; - -// component specific input validation -var _protocol = p.protocol; -var _port = p.port; -var _hostname = p.hostname; - -p.protocol = function(v, build) { - if (v !== undefined) { - if (v) { - // accept trailing :// - v = v.replace(/:(\/\/)?$/, ''); - - if (v.match(/[^a-zA-z0-9\.+-]/)) { - throw new TypeError("Protocol '" + v + "' contains characters other than [A-Z0-9.+-]"); - } - } - } - return _protocol.call(this, v, build); -}; -p.scheme = p.protocol; -p.port = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v !== undefined) { - if (v === 0) { - v = null; - } - - if (v) { - v += ""; - if (v.charAt(0) === ":") { - v = v.substring(1); - } - - if (v.match(/[^0-9]/)) { - throw new TypeError("Port '" + v + "' contains characters other than [0-9]"); - } - } - } - return _port.call(this, v, build); -}; -p.hostname = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v !== undefined) { - var x = {}; - URI.parseHost(v, x); - v = x.hostname; - } - return _hostname.call(this, v, build); -}; - -// compound accessors -p.host = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v === undefined) { - return this._parts.hostname ? URI.buildHost(this._parts) : ""; - } else { - URI.parseHost(v, this._parts); - this.build(!build); - return this; - } -}; -p.authority = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v === undefined) { - return this._parts.hostname ? URI.buildAuthority(this._parts) : ""; - } else { - URI.parseAuthority(v, this._parts); - this.build(!build); - return this; - } -}; -p.userinfo = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v === undefined) { - if (!this._parts.username) { - return ""; - } - - var t = URI.buildUserinfo(this._parts); - return t.substring(0, t.length -1); - } else { - if (v[v.length-1] !== '@') { - v += '@'; - } - - URI.parseUserinfo(v, this._parts); - this.build(!build); - return this; - } -}; -p.resource = function(v, build) { - var parts; - - if (v === undefined) { - return this.path() + this.search() + this.hash(); - } - - parts = URI.parse(v); - this._parts.path = parts.path; - this._parts.query = parts.query; - this._parts.fragment = parts.fragment; - this.build(!build); - return this; -}; - -// fraction accessors -p.subdomain = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - // convenience, return "www" from "www.example.org" - if (v === undefined) { - if (!this._parts.hostname || this.is('IP')) { - return ""; - } - - // grab domain and add another segment - var end = this._parts.hostname.length - this.domain().length - 1; - return this._parts.hostname.substring(0, end) || ""; - } else { - var e = this._parts.hostname.length - this.domain().length; - var sub = this._parts.hostname.substring(0, e); - var replace = new RegExp('^' + escapeRegEx(sub)); - - if (v && v.charAt(v.length - 1) !== '.') { - v += "."; - } - - if (v) { - URI.ensureValidHostname(v); - } - - this._parts.hostname = this._parts.hostname.replace(replace, v); - this.build(!build); - return this; - } -}; -p.domain = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (typeof v === 'boolean') { - build = v; - v = undefined; - } - - // convenience, return "example.org" from "www.example.org" - if (v === undefined) { - if (!this._parts.hostname || this.is('IP')) { - return ""; - } - - // if hostname consists of 1 or 2 segments, it must be the domain - var t = this._parts.hostname.match(/\./g); - if (t && t.length < 2) { - return this._parts.hostname; - } - - // grab tld and add another segment - var end = this._parts.hostname.length - this.tld(build).length - 1; - end = this._parts.hostname.lastIndexOf('.', end -1) + 1; - return this._parts.hostname.substring(end) || ""; - } else { - if (!v) { - throw new TypeError("cannot set domain empty"); - } - - URI.ensureValidHostname(v); - - if (!this._parts.hostname || this.is('IP')) { - this._parts.hostname = v; - } else { - var replace = new RegExp(escapeRegEx(this.domain()) + "$"); - this._parts.hostname = this._parts.hostname.replace(replace, v); - } - - this.build(!build); - return this; - } -}; -p.tld = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (typeof v === 'boolean') { - build = v; - v = undefined; - } - - // return "org" from "www.example.org" - if (v === undefined) { - if (!this._parts.hostname || this.is('IP')) { - return ""; - } - - var pos = this._parts.hostname.lastIndexOf('.'); - var tld = this._parts.hostname.substring(pos + 1); - - if (build !== true && SLD && SLD.list[tld.toLowerCase()]) { - return SLD.get(this._parts.hostname) || tld; - } - - return tld; - } else { - var replace; - - if (!v) { - throw new TypeError("cannot set TLD empty"); - } else if (v.match(/[^a-zA-Z0-9-]/)) { - if (SLD && SLD.is(v)) { - replace = new RegExp(escapeRegEx(this.tld()) + "$"); - this._parts.hostname = this._parts.hostname.replace(replace, v); - } else { - throw new TypeError("TLD '" + v + "' 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"); - } else { - replace = new RegExp(escapeRegEx(this.tld()) + "$"); - this._parts.hostname = this._parts.hostname.replace(replace, v); - } - - this.build(!build); - return this; - } -}; -p.directory = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v === undefined || v === true) { - if (!this._parts.path && !this._parts.hostname) { - return ''; - } - - if (this._parts.path === '/') { - return '/'; - } - - var end = this._parts.path.length - this.filename().length - 1; - var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : ""); - - return v ? URI.decodePath(res) : res; - - } else { - var e = this._parts.path.length - this.filename().length; - var directory = this._parts.path.substring(0, e); - var replace = new RegExp('^' + escapeRegEx(directory)); - - // fully qualifier directories begin with a slash - if (!this.is('relative')) { - if (!v) { - v = '/'; - } - - if (v.charAt(0) !== '/') { - v = "/" + v; - } - } - - // directories always end with a slash - if (v && v.charAt(v.length - 1) !== '/') { - v += '/'; - } - - v = URI.recodePath(v); - this._parts.path = this._parts.path.replace(replace, v); - this.build(!build); - return this; - } -}; -p.filename = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v === undefined || v === true) { - if (!this._parts.path || this._parts.path === '/') { - return ""; - } - - var pos = this._parts.path.lastIndexOf('/'); - var res = this._parts.path.substring(pos+1); - - return v ? URI.decodePathSegment(res) : res; - } else { - var mutatedDirectory = false; - - if (v.charAt(0) === '/') { - v = v.substring(1); - } - - if (v.match(/\.?\//)) { - mutatedDirectory = true; - } - - var replace = new RegExp(escapeRegEx(this.filename()) + "$"); - v = URI.recodePath(v); - this._parts.path = this._parts.path.replace(replace, v); - - if (mutatedDirectory) { - this.normalizePath(build); - } else { - this.build(!build); - } - - return this; - } -}; -p.suffix = function(v, build) { - if (this._parts.urn) { - return v === undefined ? '' : this; - } - - if (v === undefined || v === true) { - if (!this._parts.path || this._parts.path === '/') { - return ""; - } - - var filename = this.filename(); - var pos = filename.lastIndexOf('.'); - var s, res; - - if (pos === -1) { - return ""; - } - - // suffix may only contain alnum characters (yup, I made this up.) - s = filename.substring(pos+1); - res = (/^[a-z0-9%]+$/i).test(s) ? s : ""; - return v ? URI.decodePathSegment(res) : res; - } else { - if (v.charAt(0) === '.') { - v = v.substring(1); - } - - var suffix = this.suffix(); - var replace; - - if (!suffix) { - if (!v) { - return this; - } - - this._parts.path += '.' + URI.recodePath(v); - } else if (!v) { - replace = new RegExp(escapeRegEx("." + suffix) + "$"); - } else { - replace = new RegExp(escapeRegEx(suffix) + "$"); - } - - if (replace) { - v = URI.recodePath(v); - this._parts.path = this._parts.path.replace(replace, v); - } - - this.build(!build); - return this; - } -}; -p.segment = function(segment, v, build) { - var separator = this._parts.urn ? ':' : '/'; - var path = this.path(); - var absolute = path.substring(0, 1) === '/'; - var segments = path.split(separator); - - if (segment !== undefined && typeof segment !== 'number') { - build = v; - v = segment; - segment = undefined; - } - - if (segment !== undefined && typeof segment !== 'number') { - throw new Error("Bad segment '" + segment + "', must be 0-based integer"); - } - - if (absolute) { - segments.shift(); - } - - if (segment < 0) { - // allow negative indexes to address from the end - segment = Math.max(segments.length + segment, 0); - } - - if (v === undefined) { - return segment === undefined - ? segments - : segments[segment]; - } else if (segment === null || segments[segment] === undefined) { - if (isArray(v)) { - segments = []; - // collapse empty elements within array - for (var i=0, l=v.length; i < l; i++) { - if (!v[i].length && (!segments.length || !segments[segments.length -1].length)) { - continue; - } - - if (segments.length && !segments[segments.length -1].length) { - segments.pop(); - } - - segments.push(v[i]); - } - } else if (v || (typeof v === "string")) { - if (segments[segments.length -1] === "") { - // empty trailing elements have to be overwritten - // to prevent results such as /foo//bar - segments[segments.length -1] = v; - } else { - segments.push(v); - } - } - } else { - if (v || (typeof v === "string" && v.length)) { - segments[segment] = v; - } else { - segments.splice(segment, 1); - } - } - - if (absolute) { - segments.unshift(""); - } - - return this.path(segments.join(separator), build); -}; -p.segmentCoded = function(segment, v, build) { - var segments, i, l; - - if (typeof segment !== 'number') { - build = v; - v = segment; - segment = undefined; - } - - if (v === undefined) { - segments = this.segment(segment, v, build); - if (!isArray(segments)) { - segments = segments !== undefined ? URI.decode(segments) : undefined; - } else { - for (i = 0, l = segments.length; i < l; i++) { - segments[i] = URI.decode(segments[i]); - } - } - - return segments; - } - - if (!isArray(v)) { - v = typeof v === 'string' ? URI.encode(v) : v; - } else { - for (i = 0, l = v.length; i < l; i++) { - v[i] = URI.decode(v[i]); - } - } - - return this.segment(segment, v, build); -}; - -// mutating query string -var q = p.query; -p.query = function(v, build) { - if (v === true) { - return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); - } else if (typeof v === "function") { - var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); - var result = v.call(this, data); - this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); - this.build(!build); - return this; - } else if (v !== undefined && typeof v !== "string") { - this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); - this.build(!build); - return this; - } else { - return q.call(this, v, build); - } -}; -p.setQuery = function(name, value, build) { - var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); - - if (typeof name === "object") { - for (var key in name) { - if (hasOwn.call(name, key)) { - data[key] = name[key]; - } - } - } else if (typeof name === "string") { - data[name] = value !== undefined ? value : null; - } else { - throw new TypeError("URI.addQuery() accepts an object, string as the name parameter"); - } - - this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); - if (typeof name !== "string") { - build = value; - } - - this.build(!build); - return this; -}; -p.addQuery = function(name, value, build) { - var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); - URI.addQuery(data, name, value === undefined ? null : value); - this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); - if (typeof name !== "string") { - build = value; - } - - this.build(!build); - return this; -}; -p.removeQuery = function(name, value, build) { - var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); - URI.removeQuery(data, name, value); - this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); - if (typeof name !== "string") { - build = value; - } - - this.build(!build); - return this; -}; -p.hasQuery = function(name, value, withinArray) { - var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); - return URI.hasQuery(data, name, value, withinArray); -}; -p.setSearch = p.setQuery; -p.addSearch = p.addQuery; -p.removeSearch = p.removeQuery; -p.hasSearch = p.hasQuery; - -// sanitizing URLs -p.normalize = function() { - if (this._parts.urn) { - return this - .normalizeProtocol(false) - .normalizeQuery(false) - .normalizeFragment(false) - .build(); - } - - return this - .normalizeProtocol(false) - .normalizeHostname(false) - .normalizePort(false) - .normalizePath(false) - .normalizeQuery(false) - .normalizeFragment(false) - .build(); -}; -p.normalizeProtocol = function(build) { - if (typeof this._parts.protocol === "string") { - this._parts.protocol = this._parts.protocol.toLowerCase(); - this.build(!build); - } - - return this; -}; -p.normalizeHostname = function(build) { - if (this._parts.hostname) { - if (this.is('IDN') && punycode) { - this._parts.hostname = punycode.toASCII(this._parts.hostname); - } else if (this.is('IPv6') && IPv6) { - this._parts.hostname = IPv6.best(this._parts.hostname); - } - - this._parts.hostname = this._parts.hostname.toLowerCase(); - this.build(!build); - } - - return this; -}; -p.normalizePort = function(build) { - // remove port of it's the protocol's default - if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) { - this._parts.port = null; - this.build(!build); - } - - return this; -}; -p.normalizePath = function(build) { - if (this._parts.urn) { - return this; - } - - if (!this._parts.path || this._parts.path === '/') { - return this; - } - - var _was_relative; - var _path = this._parts.path; - var _parent, _pos; - - // handle relative paths - if (_path.charAt(0) !== '/') { - _was_relative = true; - _path = '/' + _path; - } - - // resolve simples - _path = _path - .replace(/(\/(\.\/)+)|(\/\.$)/g, '/') - .replace(/\/{2,}/g, '/'); - - // resolve parents - while (true) { - _parent = _path.indexOf('/../'); - if (_parent === -1) { - // no more ../ to resolve - break; - } else if (_parent === 0) { - // top level cannot be relative... - _path = _path.substring(3); - break; - } - - _pos = _path.substring(0, _parent).lastIndexOf('/'); - if (_pos === -1) { - _pos = _parent; - } - _path = _path.substring(0, _pos) + _path.substring(_parent + 3); - } - - // revert to relative - if (_was_relative && this.is('relative')) { - _path = _path.substring(1); - } - - _path = URI.recodePath(_path); - this._parts.path = _path; - this.build(!build); - return this; -}; -p.normalizePathname = p.normalizePath; -p.normalizeQuery = function(build) { - if (typeof this._parts.query === "string") { - if (!this._parts.query.length) { - this._parts.query = null; - } else { - this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace)); - } - - this.build(!build); - } - - return this; -}; -p.normalizeFragment = function(build) { - if (!this._parts.fragment) { - this._parts.fragment = null; - this.build(!build); - } - - return this; -}; -p.normalizeSearch = p.normalizeQuery; -p.normalizeHash = p.normalizeFragment; - -p.iso8859 = function() { - // expect unicode input, iso8859 output - var e = URI.encode; - var d = URI.decode; - - URI.encode = escape; - URI.decode = decodeURIComponent; - this.normalize(); - URI.encode = e; - URI.decode = d; - return this; -}; - -p.unicode = function() { - // expect iso8859 input, unicode output - var e = URI.encode; - var d = URI.decode; - - URI.encode = strictEncodeURIComponent; - URI.decode = unescape; - this.normalize(); - URI.encode = e; - URI.decode = d; - return this; -}; - -p.readable = function() { - var uri = this.clone(); - // removing username, password, because they shouldn't be displayed according to RFC 3986 - uri.username("").password("").normalize(); - var t = ''; - if (uri._parts.protocol) { - t += uri._parts.protocol + '://'; - } - - if (uri._parts.hostname) { - if (uri.is('punycode') && punycode) { - t += punycode.toUnicode(uri._parts.hostname); - if (uri._parts.port) { - t += ":" + uri._parts.port; - } - } else { - t += uri.host(); - } - } - - if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== '/') { - t += '/'; - } - - t += uri.path(true); - if (uri._parts.query) { - var q = ''; - for (var i = 0, qp = uri._parts.query.split('&'), l = qp.length; i < l; i++) { - var kv = (qp[i] || "").split('='); - q += '&' + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace) - .replace(/&/g, '%26'); - - if (kv[1] !== undefined) { - q += "=" + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace) - .replace(/&/g, '%26'); - } - } - t += '?' + q.substring(1); - } - - t += URI.decodeQuery(uri.hash(), true); - return t; -}; - -// resolving relative and absolute URLs -p.absoluteTo = function(base) { - var resolved = this.clone(); - var properties = ['protocol', 'username', 'password', 'hostname', 'port']; - var basedir, i, p; - - if (this._parts.urn) { - throw new Error('URNs do not have any generally defined hierarchical components'); - } - - if (!(base instanceof URI)) { - base = new URI(base); - } - - if (!resolved._parts.protocol) { - resolved._parts.protocol = base._parts.protocol; - } - - if (this._parts.hostname) { - return resolved; - } - - for (i = 0; p = properties[i]; i++) { - resolved._parts[p] = base._parts[p]; - } - - properties = ['query', 'path']; - for (i = 0; p = properties[i]; i++) { - if (!resolved._parts[p] && base._parts[p]) { - resolved._parts[p] = base._parts[p]; - } - } - - if (resolved.path().charAt(0) !== '/') { - basedir = base.directory(); - resolved._parts.path = (basedir ? (basedir + '/') : '') + resolved._parts.path; - resolved.normalizePath(); - } - - resolved.build(); - return resolved; -}; -p.relativeTo = function(base) { - var relative = this.clone().normalize(); - var relativeParts, baseParts, common, relativePath, basePath; - - if (relative._parts.urn) { - throw new Error('URNs do not have any generally defined hierarchical components'); - } - - base = new URI(base).normalize(); - relativeParts = relative._parts; - baseParts = base._parts; - relativePath = relative.path(); - basePath = base.path(); - - if (relativePath.charAt(0) !== '/') { - throw new Error('URI is already relative'); - } - - if (basePath.charAt(0) !== '/') { - throw new Error('Cannot calculate a URI relative to another relative URI'); - } - - if (relativeParts.protocol === baseParts.protocol) { - relativeParts.protocol = null; - } - - if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) { - return relative.build(); - } - - if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) { - return relative.build(); - } - - if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) { - relativeParts.hostname = null; - relativeParts.port = null; - } else { - return relative.build(); - } - - if (relativePath === basePath) { - relativeParts.path = ''; - return relative.build(); - } - - // determine common sub path - common = URI.commonPath(relative.path(), base.path()); - - // If the paths have nothing in common, return a relative URL with the absolute path. - if (!common) { - return relative.build(); - } - - var parents = baseParts.path - .substring(common.length) - .replace(/[^\/]*$/, '') - .replace(/.*?\//g, '../'); - - relativeParts.path = parents + relativeParts.path.substring(common.length); - - return relative.build(); -}; - -// comparing URIs -p.equals = function(uri) { - var one = this.clone(); - var two = new URI(uri); - var one_map = {}; - var two_map = {}; - var checked = {}; - var one_query, two_query, key; - - one.normalize(); - two.normalize(); - - // exact match - if (one.toString() === two.toString()) { - return true; - } - - // extract query string - one_query = one.query(); - two_query = two.query(); - one.query(""); - two.query(""); - - // definitely not equal if not even non-query parts match - if (one.toString() !== two.toString()) { - return false; - } - - // query parameters have the same length, even if they're permuted - if (one_query.length !== two_query.length) { - return false; - } - - one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace); - two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace); - - for (key in one_map) { - if (hasOwn.call(one_map, key)) { - if (!isArray(one_map[key])) { - if (one_map[key] !== two_map[key]) { - return false; - } - } else if (!arraysEqual(one_map[key], two_map[key])) { - return false; - } - - checked[key] = true; - } - } - - for (key in two_map) { - if (hasOwn.call(two_map, key)) { - if (!checked[key]) { - // two contains a parameter not present in one - return false; - } - } - } - - return true; -}; - -// state -p.duplicateQueryParameters = function(v) { - this._parts.duplicateQueryParameters = !!v; - return this; -}; - -p.escapeQuerySpace = function(v) { - this._parts.escapeQuerySpace = !!v; - return this; -}; - -return URI; -})); diff --git a/public/js/vendor/uri/URI.min.js b/public/js/vendor/uri/URI.min.js deleted file mode 100755 index e51ee5b32..000000000 --- a/public/js/vendor/uri/URI.min.js +++ /dev/null @@ -1,81 +0,0 @@ -/*! URI.js v1.11.2 http://medialize.github.com/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(h){h=h.toLowerCase().split(":");var f=h.length,d=8;""===h[0]&&""===h[1]&&""===h[2]?(h.shift(),h.shift()):""===h[0]&&""===h[1]?h.shift():""===h[f-1]&&""===h[f-2]&&h.pop();f=h.length;-1!==h[f-1].indexOf(".")&&(d=7);var q;for(q=0;ql;l++)if("0"===f[0]&&1l&&(f=e,l=n)):"0"==h[q]&&(u=!0,e=q,n=1);n>l&&(f=e,l=n);1=k&&c>>10&1023|55296),a=56320|a&1023);return b+=x(a)}).join("")}function q(a,b,c){var d=0;a=c?B(a/y):a>>1;for(a+=B(a/ -b);a>k*m>>1;d+=g)a=B(a/k);return B(d+(k+1)*a/(a+s))}function A(a){var b=[],c=a.length,k,e=0,f=D,h=w,x,u,v,t,s;x=a.lastIndexOf(E);0>x&&(x=0);for(u=0;u=c&&l("invalid-input");t=a.charCodeAt(x++);t=10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:g;(t>=g||t>B((C-e)/k))&&l("overflow");e+=t*k;s=v<=h?r:v>=h+m?m:v-h;if(tB(C/t)&&l("overflow");k*=t}k=b.length+1;h=q(e-u,k,0==u);B(e/k)>C- -f&&l("overflow");f+=B(e/k);e%=k;b.splice(e++,0,f)}return d(b)}function n(a){var b,c,d,k,e,f,h,u,t,v=[],s,z,n;a=p(a);s=a.length;b=D;c=0;e=w;for(f=0;ft&&v.push(x(t));for((d=k=v.length)&&v.push(E);d=b&&tB((C-c)/z)&&l("overflow");c+=(h-b)*z;b=h;for(f=0;fC&&l("overflow"),t==b){u=c;for(h=g;;h+=g){t=h<=e?r:h>=e+m?m:h-e;if(ut+n%u)-0));u=B(n/u)}v.push(x(u+22+75*(26> -u)-0));e=q(c,z,d==k);c=0;++d}++c;++b}return v.join("")}var e="object"==typeof exports&&exports,u="object"==typeof module&&module&&module.exports==e&&module,v="object"==typeof global&&global;if(v.global===v||v.window===v)f=v;var z,C=2147483647,g=36,r=1,m=26,s=38,y=700,w=72,D=128,E="-",F=/^xn--/,a=/[^ -~]/,b=/\x2E|\u3002|\uFF0E|\uFF61/g,c={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=g-r,B= -Math.floor,x=String.fromCharCode,t;z={version:"1.2.3",ucs2:{decode:p,encode:d},decode:A,encode:n,toASCII:function(c){return h(c.split(b),function(b){return a.test(b)?"xn--"+n(b):b}).join(".")},toUnicode:function(a){return h(a.split(b),function(a){return F.test(a)?A(a.slice(4).toLowerCase()):a}).join(".")}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return z});else if(e&&!e.nodeType)if(u)u.exports=z;else for(t in z)z.hasOwnProperty(t)&&(e[t]=z[t]);else f.punycode= -z})(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,h=Object.prototype.hasOwnProperty,p={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",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_expression:null,is_expression:null,has:function(d){return!!d.match(p.has_expression)}, -is:function(d){return!!d.match(p.is_expression)},get:function(d){return(d=d.match(p.has_expression))&&d[1]||null},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=l);return this},init:function(){var d="",f;for(f in p.list)h.call(p.list,f)&&(d+="|("+("("+p.list[f]+")."+f)+")");p.has_expression=RegExp("\\.("+d.substr(1)+")$","i");p.is_expression=RegExp("^("+d.substr(1)+")$","i")}};p.init();return p}); -(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,h,p){function d(a,b){if(!(this instanceof d))return new d(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b):this}function q(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, -"\\$1")}function A(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function n(a){return"Array"===A(a)}function e(a,b){var c,d;if(n(b)){c=0;for(d=b.length;c]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/;d.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"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:d.domAttributes[b]}};d.encode=z;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=z;d.decode=decodeURIComponent};d.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":"="}}}};d.encodeQuery=function(a,b){var c=d.encode(a+"");return b?c.replace(/%20/g,"+"):c};d.decodeQuery=function(a,b){a+="";try{return d.decode(b? -a.replace(/\+/g,"%20"):a)}catch(c){return a}};d.recodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;bd)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b){return a.replace(d.find_uri_expression,b)};d.ensureValidHostname=function(a){if(a.match(d.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(d.invalid_hostname_characters))throw new TypeError("Hostname '"+ -a+"' contains characters other than [A-Z0-9.-]");}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},URITemplate&&"function"==typeof URITemplate.noConflict&&(a.URITemplate=URITemplate.noConflict()),l&&"function"==typeof l.noConflict&&(a.IPv6=l.noConflict()),SecondLevelDomains&&"function"==typeof SecondLevelDomains.noConflict&&(a.SecondLevelDomains=SecondLevelDomains.noConflict()),a;p.URI===this&&(p.URI=C);return this};g.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0=== -a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};g.clone=function(){return new d(this)};g.valueOf=g.toString=function(){return this.build(!1)._string};m={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};y=function(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}};for(s in m)g[s]=y(m[s]);m={query:"?",fragment:"#"};y=function(a,b){return function(c, -d){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!d);return this}};for(s in m)g[s]=y(s,m[s]);m={search:["?","query"],hash:["#","fragment"]};y=function(a,b){return function(c,d){var e=this[a](c,d);return"string"===typeof e&&e.length?b+e:e}};for(s in m)g[s]=y(m[s][1],m[s][0]);g.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}this._parts.path=a?d.recodePath(a): -"/";this.build(!b);return this};g.path=g.pathname;g.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var k=a instanceof d,e="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(e=d.getDomAttribute(a),a=a[e]||"",e=!1);!k&&(e&&void 0!==a.pathname)&&(a=a.toString());if("string"===typeof a)this._parts=d.parse(a,this._parts);else if(k||e)for(c in k=k?a._parts:a,k)r.call(this._parts,c)&&(this._parts[c]=k[c]);else throw new TypeError("invalid input"); -this.build(!b);return this};g.is=function(a){var b=!1,c=!1,k=!1,e=!1,g=!1,f=!1,u=!1,m=!this._parts.urn;this._parts.hostname&&(m=!1,c=d.ip4_expression.test(this._parts.hostname),k=d.ip6_expression.test(this._parts.hostname),b=c||k,g=(e=!b)&&h&&h.has(this._parts.hostname),f=e&&d.idn_expression.test(this._parts.hostname),u=e&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return m;case "absolute":return!m;case "domain":case "name":return e;case "sld":return g; -case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return k;case "idn":return f;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return u}return null};var w=g.protocol,D=g.port,E=g.hostname;g.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),a.match(/[^a-zA-z0-9\.+-]/)))throw new TypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-]");return w.call(this,a,b)};g.scheme=g.protocol; -g.port=function(a,b){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 D.call(this,a,b)};g.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};d.parseHost(a,c);a=c.hostname}return E.call(this,a,b)};g.host=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname? -d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!b);return this};g.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";d.parseAuthority(a,this._parts);this.build(!b);return this};g.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var c=d.buildUserinfo(this._parts);return c.substring(0,c.length-1)}"@"!==a[a.length-1]&&(a+= -"@");d.parseUserinfo(a,this._parts);this.build(!b);return this};g.resource=function(a,b){var c;if(void 0===a)return this.path()+this.search()+this.hash();c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};g.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0, -c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=RegExp("^"+q(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(c,a);this.build(!b);return this};g.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g);if(c&&2>c.length)return this._parts.hostname; -c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=RegExp(q(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};g.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0=== -a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf("."),c=this._parts.hostname.substring(c+1);return!0!==b&&h&&h.list[c.toLowerCase()]?h.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(h&&h.is(a))c=RegExp(q(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,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"); -c=RegExp(q(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};g.directory=function(a,b){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 c=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0,c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length- -this.filename().length;c=this._parts.path.substring(0,c);c=RegExp("^"+q(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};g.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this._parts.path.lastIndexOf("/"),c=this._parts.path.substring(c+1);return a? -d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var k=RegExp(q(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(k,a);c?this.normalizePath(b):this.build(!b);return this};g.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),k=c.lastIndexOf(".");if(-1===k)return"";c=c.substring(k+1);c=/^[a-z0-9%]+$/i.test(c)?c: -"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())k=a?RegExp(q(c)+"$"):RegExp(q("."+c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}k&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(k,a));this.build(!b);return this};g.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),g="/"===e.substring(0,1),e=e.split(d);void 0!==a&&"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error("Bad segment '"+ -a+"', must be 0-based integer");g&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(n(b)){e=[];a=0;for(var f=b.length;a that is not an image - return undefined; - } - - // NOTE: as we use a static mapping from element to attribute, - // the HTML5 attribute issue should not come up again - // https://github.com/medialize/URI.js/issues/69 - return property; -} - -function generateAccessor(property) { - return { - get: function(elem) { - return $(elem).uri()[property](); - }, - set: function(elem, value) { - $(elem).uri()[property](value); - return value; - } - }; -}; - -// populate lookup table and register $.attr('uri:accessor') handlers -$.each('authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username'.split(" "), function(k, v) { - comparable[v] = true; - $.attrHooks['uri:' + v] = generateAccessor(v); -}); - -// pipe $.attr('src') and $.attr('href') through URI.js -var _attrHooks = { - get: function(elem) { - return $(elem).uri(); - }, - set: function(elem, value) { - return $(elem).uri().href(value).toString(); - } -}; -$.each(['src', 'href', 'action', 'uri', 'cite'], function(k, v) { - $.attrHooks[v] = { - set: _attrHooks.set - }; -}); -$.attrHooks.uri.get = _attrHooks.get; - -// general URI accessor -$.fn.uri = function(uri) { - var $this = this.first(); - var elem = $this.get(0); - var property = getUriProperty(elem); - - if (!property) { - throw new Error('Element "' + elem.nodeName + '" does not have either property: href, src, action, cite'); - } - - if (uri !== undefined) { - var old = $this.data('uri'); - if (old) { - return old.href(uri); - } - - if (!(uri instanceof URI)) { - uri = URI(uri || ''); - } - } else { - uri = $this.data('uri'); - if (uri) { - return uri; - } else { - uri = URI($this.attr(property) || ''); - } - } - - uri._dom_element = elem; - uri._dom_attribute = property; - uri.normalize(); - $this.data('uri', uri); - return uri; -}; - -// overwrite URI.build() to update associated DOM element if necessary -URI.prototype.build = function(deferBuild) { - if (this._dom_element) { - // cannot defer building when hooked into a DOM element - this._string = URI.build(this._parts); - this._deferred_build = false; - this._dom_element.setAttribute(this._dom_attribute, this._string); - this._dom_element[this._dom_attribute] = this._string; - } else if (deferBuild === true) { - this._deferred_build = true; - } else if (deferBuild === undefined || this._deferred_build) { - this._string = URI.build(this._parts); - this._deferred_build = false; - } - - return this; -}; - -// add :uri() pseudo class selector to sizzle -var uriSizzle; -var pseudoArgs = /^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/; -function uriPseudo (elem, text) { - var match, property, uri; - - // skip anything without src|href|action and bad :uri() syntax - if (!getUriProperty(elem) || !text) { - return false; - } - - match = text.match(pseudoArgs); - - if (!match || (!match[5] && match[2] !== ':' && !compare[match[2]])) { - // abort because the given selector cannot be executed - // filers seem to fail silently - return false; - } - - uri = $(elem).uri(); - - if (match[5]) { - return uri.is(match[5]); - } else if (match[2] === ':') { - property = match[1].toLowerCase() + ':'; - if (!compare[property]) { - // filers seem to fail silently - return false; - } - - return compare[property](uri, match[4]); - } else { - property = match[1].toLowerCase(); - if (!comparable[property]) { - // filers seem to fail silently - return false; - } - - return compare[match[2]](uri[property](), match[4], property); - } - - return false; -} - -if ($.expr.createPseudo) { - // jQuery >= 1.8 - uriSizzle = $.expr.createPseudo(function (text) { - return function (elem) { - return uriPseudo(elem, text); - }; - }); -} else { - // jQuery < 1.8 - uriSizzle = function (elem, i, match) { - return uriPseudo(elem, match[3]); - }; -} - -$.expr[":"].uri = uriSizzle; - -// extending existing object rather than defining something new -return {}; -})); diff --git a/public/js/vendor/uri/jquery.URI.min.js b/public/js/vendor/uri/jquery.URI.min.js deleted file mode 100755 index f2fcd6a88..000000000 --- a/public/js/vendor/uri/jquery.URI.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! URI.js v1.11.2 http://medialize.github.com/URI.js/ */ -/* build contains: jquery.URI.js */ -(function(d,e){"object"===typeof exports?module.exports=e(require("jquery","./URI")):"function"===typeof define&&define.amd?define(["jquery","./URI"],e):e(d.jQuery,d.URI)})(this,function(d,e){function h(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function k(a){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:e.domAttributes[b]}function p(a){return{get:function(b){return d(b).uri()[a]()},set:function(b,c){d(b).uri()[a](c);return c}}}function l(a,b){var c,e,f;if(!k(a)|| -!b)return!1;c=b.match(q);if(!c||!c[5]&&":"!==c[2]&&!g[c[2]])return!1;f=d(a).uri();if(c[5])return f.is(c[5]);if(":"===c[2])return e=c[1].toLowerCase()+":",g[e]?g[e](f,c[4]):!1;e=c[1].toLowerCase();return m[e]?g[c[2]](f[e](),c[4],e):!1}var m={},g={"=":function(a,b){return a===b},"^=":function(a,b,c){return!!(a+"").match(RegExp("^"+h(b),"i"))},"$=":function(a,b,c){return!!(a+"").match(RegExp(h(b)+"$","i"))},"*=":function(a,b,c){"directory"==c&&(a+="/");return!!(a+"").match(RegExp(h(b),"i"))},"equals:":function(a, -b){return a.equals(b)},"is:":function(a,b){return a.is(b)}};d.each("authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username".split(" "),function(a,b){m[b]=!0;d.attrHooks["uri:"+b]=p(b)});var r=function(a,b){return d(a).uri().href(b).toString()};d.each(["src","href","action","uri","cite"],function(a,b){d.attrHooks[b]={set:r}});d.attrHooks.uri.get=function(a){return d(a).uri()};d.fn.uri=function(a){var b= -this.first(),c=b.get(0),d=k(c);if(!d)throw Error('Element "'+c.nodeName+'" does not have either property: href, src, action, cite');if(void 0!==a){var f=b.data("uri");if(f)return f.href(a);a instanceof e||(a=e(a||""))}else{if(a=b.data("uri"))return a;a=e(b.attr(d)||"")}a._dom_element=c;a._dom_attribute=d;a.normalize();b.data("uri",a);return a};e.prototype.build=function(a){if(this._dom_element)this._string=e.build(this._parts),this._deferred_build=!1,this._dom_element.setAttribute(this._dom_attribute, -this._string),this._dom_element[this._dom_attribute]=this._string;else if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=e.build(this._parts),this._deferred_build=!1;return this};var n,q=/^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;n=d.expr.createPseudo?d.expr.createPseudo(function(a){return function(b){return l(b,a)}}):function(a,b,c){return l(a,c[3])};d.expr[":"].uri=n;return{}}); \ No newline at end of file diff --git a/public/js/vendor/uri/punycode.js b/public/js/vendor/uri/punycode.js deleted file mode 100755 index 41803ba42..000000000 --- a/public/js/vendor/uri/punycode.js +++ /dev/null @@ -1,508 +0,0 @@ -/*! http://mths.be/punycode v1.2.3 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports; - var freeModule = typeof module == 'object' && module && - module.exports == freeExports && module; - var freeGlobal = typeof global == 'object' && global; - if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - while (length--) { - array[length] = fn(array[length]); - } - return array; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings. - * @private - * @param {String} domain The domain name. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - return map(string.split(regexSeparators), fn).join('.'); - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * http://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - length, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols to a Punycode string of ASCII-only - * symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name to Unicode. Only the - * Punycoded parts of the domain name will be converted, i.e. it doesn't - * matter if you call it on a string that has already been converted to - * Unicode. - * @memberOf punycode - * @param {String} domain The Punycode domain name to convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(domain) { - return mapDomain(domain, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name to Punycode. Only the - * non-ASCII parts of the domain name will be converted, i.e. it doesn't - * matter if you call it with a domain that's already in ASCII. - * @memberOf punycode - * @param {String} domain The domain name to convert, as a Unicode string. - * @returns {String} The Punycode representation of the given domain name. - */ - function toASCII(domain) { - return mapDomain(domain, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.2.3', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; - - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define(function() { - return punycode; - }); - } else if (freeExports && !freeExports.nodeType) { - if (freeModule) { // in Node.js or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { // in Rhino or a web browser - root.punycode = punycode; - } - -}(this));