Skip to content

Commit 4b3f66b

Browse files
committed
upd:删掉重复代码
1 parent 77a3b2d commit 4b3f66b

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

dist/cos-js-sdk-v5.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ function getObjectKeys(obj, forKey) {
106106
/**
107107
* obj转为string
108108
* @param {Object} obj 需要转的对象,必须
109-
* @param {Object} stayCase 保留原始大小写,默认false,非必须
110-
* @return {String} data 返回字符串
109+
* @param {Boolean} stayCase 保留原始大小写,默认false,非必须
110+
* @return {String} data 返回字符串
111111
*/
112112
var obj2str = function (obj, stayCase) {
113113
var i, key, val;
@@ -7881,20 +7881,14 @@ function getObjectUrl(params, callback) {
78817881
queryParamsStr += (queryParamsStr ? '&' : '') + params.QueryString;
78827882
}
78837883

7884-
// 签名加上 Host,避免跨桶访问
7885-
var SignHost = '';
7886-
var standardHost = 'cos.' + params.Region + '.myqcloud.com';
7887-
if (!self.options.ForcePathStyle) standardHost = params.Bucket + '.' + standardHost;
7888-
var urlHost = url.replace(/^https?:\/\/([^/]+)(\/.*)?$/, '$1');
7889-
if (standardHost === urlHost) SignHost = standardHost;
7890-
78917884
var syncUrl = url;
78927885
if (params.Sign !== undefined && !params.Sign) {
78937886
queryParamsStr && (syncUrl += '?' + queryParamsStr);
78947887
callback(null, { Url: syncUrl });
78957888
return syncUrl;
78967889
}
78977890

7891+
// 签名加上 Host,避免跨桶访问
78987892
var SignHost = getSignHost.call(this, { Bucket: params.Bucket, Region: params.Region, Url: url });
78997893
var AuthData = getAuthorizationAsync.call(this, {
79007894
Action: (params.Method || '').toUpperCase() === 'PUT' ? 'name/cos:PutObject' : 'name/cos:GetObject',

dist/cos-js-sdk-v5.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -3007,20 +3007,14 @@ function getObjectUrl(params, callback) {
30073007
queryParamsStr += (queryParamsStr ? '&' : '') + params.QueryString;
30083008
}
30093009

3010-
// 签名加上 Host,避免跨桶访问
3011-
var SignHost = '';
3012-
var standardHost = 'cos.' + params.Region + '.myqcloud.com';
3013-
if (!self.options.ForcePathStyle) standardHost = params.Bucket + '.' + standardHost;
3014-
var urlHost = url.replace(/^https?:\/\/([^/]+)(\/.*)?$/, '$1');
3015-
if (standardHost === urlHost) SignHost = standardHost;
3016-
30173010
var syncUrl = url;
30183011
if (params.Sign !== undefined && !params.Sign) {
30193012
queryParamsStr && (syncUrl += '?' + queryParamsStr);
30203013
callback(null, {Url: syncUrl});
30213014
return syncUrl;
30223015
}
30233016

3017+
// 签名加上 Host,避免跨桶访问
30243018
var SignHost = getSignHost.call(this, {Bucket: params.Bucket, Region: params.Region, Url: url});
30253019
var AuthData = getAuthorizationAsync.call(this, {
30263020
Action: ((params.Method || '').toUpperCase() === 'PUT' ? 'name/cos:PutObject' : 'name/cos:GetObject'),

0 commit comments

Comments
 (0)