// License: http://unlicense.org/ (i.e. do what you want with it!)
jQuery.url = function()
{
var segments = {};
var parsed = {};
/**
* Options object. Only the URI and strictMode values can be changed via the setters below.
*/
var options = {
url : window.location, // default URI is the page in which the script is running
strictMode: false, // 'loose' parsing by default
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], // keys available to query
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, //less intuitive, more accurate to the specs
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // more intuitive, fails on relative paths and deviates from specs
}
};
/**
* Deals with the parsing of the URI according to the regex above.
* Written by Steven Levithan - see credits at top.
*/
var parseUri = function()
{
str = decodeURI( options.url );
var m = options.parser[ options.strictMode ? "strict" : "loose" ].exec( str );