-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Franz Enzenhofer
committed
Jun 4, 2011
0 parents
commit 3051403
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// a node.js module fork of | ||
// parseUri 1.2.2 | ||
// (c) Steven Levithan <stevenlevithan.com> | ||
// MIT License | ||
// see: http://blog.stevenlevithan.com/archives/parseuri | ||
// see: http://stevenlevithan.com/demo/parseuri/js/ | ||
|
||
//forked into a node.js module by franz enzenhofer | ||
|
||
|
||
function parseUri (str) { | ||
var o = parseUri.options, | ||
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), | ||
uri = {}, | ||
i = 14; | ||
|
||
while (i--) uri[o.key[i]] = m[i] || ""; | ||
|
||
uri[o.q.name] = {}; | ||
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { | ||
if ($1) uri[o.q.name][$1] = $2; | ||
}); | ||
|
||
return uri; | ||
}; | ||
|
||
parseUri.options = { | ||
strictMode: false, | ||
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], | ||
q: { | ||
name: "queryKey", | ||
parser: /(?:^|&)([^&=]*)=?([^&]*)/g | ||
}, | ||
parser: { | ||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, | ||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ | ||
} | ||
}; | ||
|
||
module.exports = parseUri |