summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/url.js b/lib/url.js
index f10ba5fb0b..887ac0c432 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -20,6 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var punycode = require('punycode');
+var util = require('util');
exports.parse = urlParse;
exports.resolve = urlResolve;
@@ -94,7 +95,7 @@ var protocolPattern = /^([a-z0-9.+-]+:)/i,
querystring = require('querystring');
function urlParse(url, parseQueryString, slashesDenoteHost) {
- if (url && IS_OBJECT(url) && url instanceof Url) return url;
+ if (url && util.isObject(url) && url instanceof Url) return url;
var u = new Url;
u.parse(url, parseQueryString, slashesDenoteHost);
@@ -102,7 +103,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
}
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
- if (!IS_STRING(url)) {
+ if (!util.isString(url)) {
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
}
@@ -340,7 +341,7 @@ function urlFormat(obj) {
// If it's an obj, this is a no-op.
// this way, you can call url_format() on strings
// to clean up potentially wonky urls.
- if (IS_STRING(obj)) obj = urlParse(obj);
+ if (util.isString(obj)) obj = urlParse(obj);
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
return obj.format();
}
@@ -370,7 +371,9 @@ Url.prototype.format = function() {
}
}
- if (this.query && IS_OBJECT(this.query) && Object.keys(this.query).length) {
+ if (this.query &&
+ util.isObject(this.query) &&
+ Object.keys(this.query).length) {
query = querystring.stringify(this.query);
}
@@ -413,7 +416,7 @@ function urlResolveObject(source, relative) {
}
Url.prototype.resolveObject = function(relative) {
- if (IS_STRING(relative)) {
+ if (util.isString(relative)) {
var rel = new Url();
rel.parse(relative, false, true);
relative = rel;
@@ -553,7 +556,7 @@ Url.prototype.resolveObject = function(relative) {
srcPath = srcPath.concat(relPath);
result.search = relative.search;
result.query = relative.query;
- } else if (!IS_NULL_OR_UNDEFINED(relative.search)) {
+ } else if (!util.isNullOrUndefined(relative.search)) {
// just pull out the search.
// like href='?foo'.
// Put this after the other two cases because it simplifies the booleans
@@ -572,7 +575,7 @@ Url.prototype.resolveObject = function(relative) {
result.search = relative.search;
result.query = relative.query;
//to support http.request
- if (!IS_NULL(result.pathname) || !IS_NULL(result.search)) {
+ if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
result.path = (result.pathname ? result.pathname : '') +
(result.search ? result.search : '');
}
@@ -666,7 +669,7 @@ Url.prototype.resolveObject = function(relative) {
}
//to support request.http
- if (!IS_NULL(result.pathname) || !IS_NULL(result.search)) {
+ if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
result.path = (result.pathname ? result.pathname : '') +
(result.search ? result.search : '');
}