removed inline require call for querystring
This commit is contained in:
parent
c86c614cac
commit
3669c75f4d
@ -1,4 +1,3 @@
|
||||
|
||||
exports.parse = url_parse;
|
||||
exports.resolve = url_resolve;
|
||||
exports.resolveObject = url_resolveObject;
|
||||
@ -17,7 +16,7 @@ var protocolPattern = /^([a-z0-9]+:)/,
|
||||
"http:":true, "https:":true, "ftp:":true, "gopher:":true, "file:":true
|
||||
},
|
||||
path = require("path"), // internal module, guaranteed to be loaded already.
|
||||
querystring; // don't load unless necessary.
|
||||
querystring = require('querystring');
|
||||
|
||||
function url_parse (url, parseQueryString) {
|
||||
if (url && typeof(url) === "object" && url.href) return url;
|
||||
@ -75,9 +74,6 @@ function url_parse (url, parseQueryString) {
|
||||
out.search = rest.substr(qm);
|
||||
out.query = rest.substr(qm+1);
|
||||
if (parseQueryString) {
|
||||
if (!querystring) {
|
||||
querystring = require("querystring");
|
||||
}
|
||||
out.query = querystring.parse(out.query);
|
||||
}
|
||||
rest = rest.slice(0, qm);
|
||||
@ -105,7 +101,7 @@ function url_format (obj) {
|
||||
search = obj.search || (
|
||||
obj.query && ( "?" + (
|
||||
typeof(obj.query) === "object"
|
||||
? require("querystring").stringify(obj.query)
|
||||
? querystring.stringify(obj.query)
|
||||
: String(obj.query)
|
||||
))
|
||||
) || "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user