Skip to content

Commit

Permalink
Always clobber internal objects for qs but preserve old querystring a…
Browse files Browse the repository at this point in the history
…rgs when clobber is present.
  • Loading branch information
mikeal committed Mar 11, 2012
1 parent 047b7b5 commit 6fda9d7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,17 +598,17 @@ Request.prototype.setHeaders = function (headers) {
return this
}
Request.prototype.qs = function (q, clobber) {
var uri = {
protocol: this.uri.protocol,
host: this.uri.host,
pathname: this.uri.pathname,
query: clobber ? q : qs.parse(this.uri.query),
hash: this.uri.hash
};
if (!clobber) for (var i in q) uri.query[i] = q[i]

this.uri= url.parse(url.format(uri))

var base
if (!clobber && this.uri.query) base = qs.parse(this.uri.query)
else base = {}

for (var i in q) {
base[i] = q[i]
}

this.uri = url.parse(this.uri.href.split('?')[0] + '?' + qs.stringify(base))
this.url = this.uri
return this
}
Request.prototype.form = function (form) {
Expand Down

0 comments on commit 6fda9d7

Please sign in to comment.