(function(n){typeof define=="function"&&define.amd?define(n):window.purl=n()})(function(){function c(n,t){for(var u=decodeURI(n),e=h[t||!1?"strict":"loose"].exec(u),i={attr:{},param:{},seg:{}},r=14;r--;)i.attr[o[r]]=e[r]||"";return i.param.query=f(i.attr.query),i.param.fragment=f(i.attr.fragment),i.seg.path=i.attr.path.replace(/^\/+|\/+$/g,"").split("/"),i.seg.fragment=i.attr.fragment.replace(/^\/+|\/+$/g,"").split("/"),i.attr.base=i.attr.host?(i.attr.protocol?i.attr.protocol+"://"+i.attr.host:i.attr.host)+(i.attr.port?":"+i.attr.port:""):"",i}function l(n){var t=n.tagName;return typeof t!="undefined"?e[t.toLowerCase()]:t}function u(n,t){var i,r;if(n[t].length===0)return n[t]={};i={};for(r in n[t])i[r]=n[t][r];return n[t]=i,i}function r(t,f,e,o){var h=t.shift(),s;h?(s=f[e]=f[e]||[],"]"==h?n(s)?""!==o&&s.push(o):"object"==typeof s?s[w(s).length]=o:s=f[e]=[f[e],o]:~h.indexOf("]")?(h=h.substr(0,h.length-1),!i.test(h)&&n(s)&&(s=u(f,e)),r(t,s,h,o)):(!i.test(h)&&n(s)&&(s=u(f,e)),r(t,s,h,o))):n(f[e])?f[e].push(o):f[e]="object"==typeof f[e]?o:"undefined"==typeof f[e]?o:[f[e],o]}function a(t,u,f){var s,e,o;if(~u.indexOf("]"))s=u.split("["),r(s,t,"base",f);else{if(!i.test(u)&&n(t.base)){e={};for(o in t.base)e[o]=t.base[o];t.base=e}u!==""&&v(t.base,u,f)}return t}function f(n){return p(String(n).split(/&|;/),function(n,t){try{t=decodeURIComponent(t.replace(/\+/g," "))}catch(e){}var u=t.indexOf("="),f=y(t),r=t.substr(0,f||u),i=t.substr(f||u,t.length);return i=i.substr(i.indexOf("=")+1,i.length),r===""&&(r=t,i=""),a(n,r,i)},{base:{}}).base}function v(t,i,r){var u=t[i];typeof u=="undefined"?t[i]=r:n(u)?u.push(r):t[i]=[u,r]}function y(n){for(var u=n.length,r,t,i=0;i<u;++i)if(t=n[i],"]"==t&&(r=!1),"["==t&&(r=!0),"="==t&&!r)return i}function p(n,t){for(var i=0,u=n.length>>0,r=arguments[2];i<u;)i in n&&(r=t.call(undefined,r,n[i],i,n)),++i;return r}function n(n){return Object.prototype.toString.call(n)==="[object Array]"}function w(n){var t=[];for(var i in n)n.hasOwnProperty(i)&&t.push(i);return t}function t(n,t){return arguments.length===1&&n===!0&&(t=!0,n=undefined),t=t||!1,n=n||window.location.toString(),{data:c(n,t),attr:function(n){return n=s[n]||n,typeof n!="undefined"?this.data.attr[n]:this.data.attr},param:function(n){return typeof n!="undefined"?this.data.param.query[n]:this.data.param.query},fparam:function(n){return typeof n!="undefined"?this.data.param.fragment[n]:this.data.param.fragment},segment:function(n){return typeof n=="undefined"?this.data.seg.path:(n=n<0?this.data.seg.path.length+n:n-1,this.data.seg.path[n])},fsegment:function(n){return typeof n=="undefined"?this.data.seg.fragment:(n=n<0?this.data.seg.fragment.length+n:n-1,this.data.seg.fragment[n])}}}var e={a:"href",img:"src",form:"action",base:"href",script:"src",iframe:"src",link:"href",embed:"src",object:"data"},o=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","fragment"],s={anchor:"fragment"},h={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},i=/^[0-9]+$/;return t.jQuery=function(n){n!=null&&(n.fn.url=function(i){var r="";return this.length&&(r=n(this).attr(l(this[0]))||""),t(r,i)},n.url=t)},t.jQuery(window.jQuery),t})