summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/url.js b/lib/url.js
index 49030268e9..f10ba5fb0b 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -94,7 +94,7 @@ var protocolPattern = /^([a-z0-9.+-]+:)/i,
querystring = require('querystring');
function urlParse(url, parseQueryString, slashesDenoteHost) {
- if (url && typeof(url) === 'object' && url instanceof Url) return url;
+ if (url && IS_OBJECT(url) && url instanceof Url) return url;
var u = new Url;
u.parse(url, parseQueryString, slashesDenoteHost);
@@ -102,7 +102,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
}
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
- if (typeof url !== 'string') {
+ if (!IS_STRING(url)) {
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
}
@@ -340,7 +340,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 (typeof(obj) === 'string') obj = urlParse(obj);
+ if (IS_STRING(obj)) obj = urlParse(obj);
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
return obj.format();
}
@@ -370,8 +370,7 @@ Url.prototype.format = function() {
}
}
- if (this.query && typeof this.query === 'object' &&
- Object.keys(this.query).length) {
+ if (this.query && IS_OBJECT(this.query) && Object.keys(this.query).length) {
query = querystring.stringify(this.query);
}
@@ -414,7 +413,7 @@ function urlResolveObject(source, relative) {
}
Url.prototype.resolveObject = function(relative) {
- if (typeof relative === 'string') {
+ if (IS_STRING(relative)) {
var rel = new Url();
rel.parse(relative, false, true);
relative = rel;
@@ -554,7 +553,7 @@ Url.prototype.resolveObject = function(relative) {
srcPath = srcPath.concat(relPath);
result.search = relative.search;
result.query = relative.query;
- } else if (relative.search !== null && relative.search !== undefined) {
+ } else if (!IS_NULL_OR_UNDEFINED(relative.search)) {
// just pull out the search.
// like href='?foo'.
// Put this after the other two cases because it simplifies the booleans
@@ -573,7 +572,7 @@ Url.prototype.resolveObject = function(relative) {
result.search = relative.search;
result.query = relative.query;
//to support http.request
- if (result.pathname !== null || result.search !== null) {
+ if (!IS_NULL(result.pathname) || !IS_NULL(result.search)) {
result.path = (result.pathname ? result.pathname : '') +
(result.search ? result.search : '');
}
@@ -667,7 +666,7 @@ Url.prototype.resolveObject = function(relative) {
}
//to support request.http
- if (result.pathname !== null || result.search !== null) {
+ if (!IS_NULL(result.pathname) || !IS_NULL(result.search)) {
result.path = (result.pathname ? result.pathname : '') +
(result.search ? result.search : '');
}