File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,26 @@ module.exports = function (superagent) {
7
7
8
8
var Request = superagent . Request ;
9
9
10
+ /**
11
+ * Override .query() to collect the query values.
12
+ * XXX: it would be nice if superagent offered an API for this...
13
+ *
14
+ * @api public
15
+ */
16
+
17
+ var oldQuery = Request . prototype . query ;
18
+
19
+ Request . prototype . query = function ( obj ) {
20
+ if ( ! this . _oauth_query ) this . _oauth_query = { } ;
21
+ // merge
22
+ var keys = Object . keys ( obj ) , key ;
23
+ for ( var i = 0 ; i < keys . length ; i ++ ) {
24
+ key = keys [ i ] ;
25
+ this . _oauth_query [ key ] = obj [ keys ] ;
26
+ }
27
+ return oldQuery . call ( this , obj ) ;
28
+ } ;
29
+
10
30
/**
11
31
* Add sign method.
12
32
*
@@ -39,7 +59,7 @@ module.exports = function (superagent) {
39
59
, this . secret
40
60
, this . method
41
61
, this . url
42
- , this . _data || this . _query // XXX: what if there's query and body? merge?
62
+ , this . _data || this . _oauth_query // XXX: what if there's query and body? merge?
43
63
) ;
44
64
45
65
var header = this . oa . _isEcho
You can’t perform that action at this time.
0 commit comments