Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "lil-uri", | ||
"description": "Tiny URI parser and builder with chainable API", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "lil-js/uri", |
{ | ||
"name": "lil-uri", | ||
"description": "Tiny URI parser and builder", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "lil-js/uri", |
{ | ||
"name": "lil-uri", | ||
"description": "Tiny URI parser and builder with chainable API", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "lil-js/uri", |
12
uri.js
@@ -15,8 +15,12 @@ /*! lil-uri - v0.2.0 - MIT License - https://github.com/lil-js/uri */ | ||
'use strict' | ||
var VERSION = '0.2.0' | ||
var VERSION = '0.2.1' | ||
var REGEX = /^(?:([^:\/?#]+):\/\/)?((?:([^\/?#@]*)@)?([^\/?#:]*)(?:\:(\d*))?)?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n)*))?/i | ||
function isStr(o) { | ||
function isStr (o) { | ||
return typeof o === 'string' | ||
} | ||
function decode (uri) { | ||
return decodeURIComponent(escape(uri)) | ||
} | ||
@@ -42,3 +46,3 @@ function mapSearchParams(search) { | ||
if (value) { | ||
this.parts[type] = isStr(value) ? decodeURIComponent(value) : value | ||
this.parts[type] = isStr(value) ? decode(value) : value | ||
return this | ||
@@ -61,3 +65,3 @@ } | ||
URI.prototype.parse = function (uri) { | ||
var parts = decodeURIComponent(uri || '').match(REGEX) | ||
var parts = decode(uri || '').match(REGEX) | ||
var auth = (parts[3] || '').split(':') | ||
@@ -64,0 +68,0 @@ var host = auth.length ? (parts[2] || '').replace(/(.*\@)/, '') : parts[2] |
/*! lil-uri - v0.2.0 - MIT License - https://github.com/lil-js/uri */ | ||
(function(t,r){if(typeof define==="function"&&define.amd){define(["exports"],r)}else if(typeof exports==="object"){r(exports);if(typeof module==="object"&&module!==null){module.exports=exports=exports.uri}}else{r(t.lil=t.lil||{})}})(this,function(t){"use strict";var r="0.2.0";var e=/^(?:([^:\/?#]+):\/\/)?((?:([^\/?#@]*)@)?([^\/?#:]*)(?:\:(\d*))?)?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n)*))?/i;function o(t){return typeof t==="string"}function s(t){var r={};if(typeof t==="string"){t.split("&").forEach(function(t){t=t.split("=");if(r.hasOwnProperty(t[0])){r[t[0]]=Array.isArray(r[t[0]])?r[t[0]]:[r[t[0]]];r[t[0]].push(t[1])}else{r[t[0]]=t[1]}});return r}}function n(t){return function(r){if(r){this.parts[t]=o(r)?decodeURIComponent(r):r;return this}this.parts=this.parse(this.build());return this.parts[t]}}function i(t){this.uri=t||null;if(o(t)&&t.length){this.parts=this.parse(t)}else{this.parts={}}}i.prototype.parse=function(t){var r=decodeURIComponent(t||"").match(e);var o=(r[3]||"").split(":");var n=o.length?(r[2]||"").replace(/(.*\@)/,""):r[2];return{uri:r[0],protocol:r[1],host:n,hostname:r[4],port:r[5],auth:r[3],user:o[0],password:o[1],path:r[6],search:r[7],query:s(r[7]),hash:r[8]}};i.prototype.protocol=function(t){return n("protocol").call(this,t)};i.prototype.host=function(t){return n("host").call(this,t)};i.prototype.hostname=function(t){return n("hostname").call(this,t)};i.prototype.port=function(t){return n("port").call(this,t)};i.prototype.auth=function(t){return n("host").call(this,t)};i.prototype.user=function(t){return n("user").call(this,t)};i.prototype.password=function(t){return n("password").call(this,t)};i.prototype.path=function(t){return n("path").call(this,t)};i.prototype.search=function(t){return n("search").call(this,t)};i.prototype.query=function(t){return t&&typeof t==="object"?n("query").call(this,t):this.parts.query};i.prototype.hash=function(t){return n("hash").call(this,t)};i.prototype.get=function(t){return this.parts[t]||""};i.prototype.build=i.prototype.toString=i.prototype.valueOf=function(){var t=this.parts,r=[];if(t.protocol)r.push(t.protocol+"://");if(t.auth)r.push(t.auth+"@");else if(t.user)r.push(t.user+(t.password?":"+t.password:"")+"@");if(t.host){r.push(t.host)}else{if(t.hostname)r.push(t.hostname);if(t.port)r.push(":"+t.port)}if(t.path)r.push(t.path);if(t.query&&typeof t.query==="object"){if(!t.path)r.push("/");r.push("?"+Object.keys(t.query).map(function(r){if(Array.isArray(t.query[r])){return t.query[r].map(function(t){return r+(t?"="+t:"")}).join("&")}else{return r+(t.query[r]?"="+t.query[r]:"")}}).join("&"))}else if(t.search){r.push("?"+t.search)}if(t.hash){if(!t.path)r.push("/");r.push("#"+t.hash)}return this.url=r.filter(function(t){return o(t)}).join("")};function p(t){return new i(t)}function u(t){return typeof t==="string"&&e.test(t)}p.VERSION=r;p.is=p.isURL=u;p.URI=i;return t.uri=p}); | ||
(function(t,r){if(typeof define==="function"&&define.amd){define(["exports"],r)}else if(typeof exports==="object"){r(exports);if(typeof module==="object"&&module!==null){module.exports=exports=exports.uri}}else{r(t.lil=t.lil||{})}})(this,function(t){"use strict";var r="0.2.0";var e=/^(?:([^:\/?#]+):\/\/)?((?:([^\/?#@]*)@)?([^\/?#:]*)(?:\:(\d*))?)?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n)*))?/i;function o(t){return typeof t==="string"}function s(t){return decodeURIComponent(escape(t))}function n(t){var r={};if(typeof t==="string"){t.split("&").forEach(function(t){t=t.split("=");if(r.hasOwnProperty(t[0])){r[t[0]]=Array.isArray(r[t[0]])?r[t[0]]:[r[t[0]]];r[t[0]].push(t[1])}else{r[t[0]]=t[1]}});return r}}function i(t){return function(r){if(r){this.parts[t]=o(r)?s(r):r;return this}this.parts=this.parse(this.build());return this.parts[t]}}function u(t){this.uri=t||null;if(o(t)&&t.length){this.parts=this.parse(t)}else{this.parts={}}}u.prototype.parse=function(t){var r=s(t||"").match(e);var o=(r[3]||"").split(":");var i=o.length?(r[2]||"").replace(/(.*\@)/,""):r[2];return{uri:r[0],protocol:r[1],host:i,hostname:r[4],port:r[5],auth:r[3],user:o[0],password:o[1],path:r[6],search:r[7],query:n(r[7]),hash:r[8]}};u.prototype.protocol=function(t){return i("protocol").call(this,t)};u.prototype.host=function(t){return i("host").call(this,t)};u.prototype.hostname=function(t){return i("hostname").call(this,t)};u.prototype.port=function(t){return i("port").call(this,t)};u.prototype.auth=function(t){return i("host").call(this,t)};u.prototype.user=function(t){return i("user").call(this,t)};u.prototype.password=function(t){return i("password").call(this,t)};u.prototype.path=function(t){return i("path").call(this,t)};u.prototype.search=function(t){return i("search").call(this,t)};u.prototype.query=function(t){return t&&typeof t==="object"?i("query").call(this,t):this.parts.query};u.prototype.hash=function(t){return i("hash").call(this,t)};u.prototype.get=function(t){return this.parts[t]||""};u.prototype.build=u.prototype.toString=u.prototype.valueOf=function(){var t=this.parts,r=[];if(t.protocol)r.push(t.protocol+"://");if(t.auth)r.push(t.auth+"@");else if(t.user)r.push(t.user+(t.password?":"+t.password:"")+"@");if(t.host){r.push(t.host)}else{if(t.hostname)r.push(t.hostname);if(t.port)r.push(":"+t.port)}if(t.path)r.push(t.path);if(t.query&&typeof t.query==="object"){if(!t.path)r.push("/");r.push("?"+Object.keys(t.query).map(function(r){if(Array.isArray(t.query[r])){return t.query[r].map(function(t){return r+(t?"="+t:"")}).join("&")}else{return r+(t.query[r]?"="+t.query[r]:"")}}).join("&"))}else if(t.search){r.push("?"+t.search)}if(t.hash){if(!t.path)r.push("/");r.push("#"+t.hash)}return this.url=r.filter(function(t){return o(t)}).join("")};function p(t){return new u(t)}function h(t){return typeof t==="string"&&e.test(t)}p.VERSION=r;p.is=p.isURL=h;p.URI=u;return t.uri=p}); | ||
//# sourceMappingURL=http://cdn.rawgit.com/lil-js/uri/0.2.0/uri.min.js.map |
Sorry, the diff of this file is not supported yet
30657
487