--- /dev/null
+\r
+\r
+/**************************************************************\r
+\r
+ Script : URL Parser\r
+ Version : 1.0\r
+ Authors : Steven Levithan\r
+ Desc : Splits any well-formed URL\r
+\r
+**************************************************************/\r
+\r
+function parseUrl(sourceUrl){\r
+ var urlPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];\r
+ var urlParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUrl);\r
+ var url = {};\r
+ \r
+ for(var i = 0; i < 10; i++){\r
+ url[urlPartNames[i]] = (urlParts[i] ? urlParts[i] : "");\r
+ }\r
+ \r
+ // Always end directoryPath with a trailing backslash if a path was present in the source URI\r
+ // Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key\r
+ if(url.directoryPath.length > 0){\r
+ url.directoryPath = url.directoryPath.replace(/\/?$/, "/");\r
+ }\r
+ \r
+ return url;\r
+}\r
+\r
+/*************************************************************/\r