Skip to content

Commit

Permalink
修复 query 参数漏传
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Jan 12, 2018
1 parent 244cb83 commit 49edfd7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions lib/request.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
var obj2str = function (obj) {
var i, key, val;
var list = [];
var keyList = Object.keys(obj);
for (i = 0; i < keyList.length; i++) {
key = keyList[i];
val = obj[key] || '';
list.push(key + '=' + encodeURIComponent(val));
}
return list.join('&');
};

var request = function (params, callback) {
var filePath = params.filePath;
var headers = params.headers;
Expand Down Expand Up @@ -40,6 +52,10 @@ var request = function (params, callback) {
});
});
} else {
var qsStr = params.qs && obj2str(params.qs) || '';
if (qsStr) {
url += (url.indexOf('?') > -1 ? '&' : '?') + qsStr;
}
wx.request({
url: url,
method: method,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cos-wx-sdk-v5",
"version": "1.0.0",
"version": "0.4.0",
"description": "wx-sdk-v5 for [腾讯云对象存储服务](http://wiki.qcloud.com/wiki/COS%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D)",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ var COS = function (options) {
util.extend(COS.prototype, base);

COS.getAuthorization = util.getAuth;
COS.version = '0.3.5';
COS.version = '0.4.0';

module.exports = COS;

0 comments on commit 49edfd7

Please sign in to comment.