Skip to content

Commit e27a81d

Browse files
committed
fix:修复host签名时不兼容全球加速域名
1 parent be859ab commit e27a81d

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

dist/cos-js-sdk-v5.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,7 +2485,7 @@ COS.util = {
24852485
json2xml: util.json2xml
24862486
};
24872487
COS.getAuthorization = util.getAuth;
2488-
COS.version = '1.3.3';
2488+
COS.version = '1.3.4';
24892489

24902490
module.exports = COS;
24912491

@@ -8049,13 +8049,17 @@ function getUrl(params) {
80498049
}
80508050

80518051
var getSignHost = function (opt) {
8052-
if (!opt.Bucket || !opt.Bucket) return '';
8052+
if (!opt.Bucket || !opt.Region) return '';
8053+
var region = opt.Region;
8054+
if (this.options.UseAccelerate) {
8055+
region = 'accelerate';
8056+
}
80538057
var url = opt.Url || getUrl({
80548058
ForcePathStyle: this.options.ForcePathStyle,
80558059
protocol: this.options.Protocol,
80568060
domain: this.options.Domain,
80578061
bucket: opt.Bucket,
8058-
region: opt.Region
8062+
region: region
80598063
});
80608064
var urlHost = url.replace(/^https?:\/\/([^/]+)(\/.*)?$/, '$1');
80618065
var standardHostReg = new RegExp('^([a-z\\d-]+-\\d+\\.)?(cos|cosv6|ci|pic)\\.([a-z\\d-]+)\\.myqcloud\\.com$');
@@ -8065,7 +8069,6 @@ var getSignHost = function (opt) {
80658069

80668070
// 异步获取签名
80678071
function getAuthorizationAsync(params, callback) {
8068-
80698072
var headers = util.clone(params.Headers);
80708073
var headerHost = '';
80718074
util.each(headers, function (v, k) {

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-js-sdk-v5",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
44
"description": "JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)",
55
"main": "index.js",
66
"types": "index.d.ts",

src/base.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,13 +3183,17 @@ function getUrl(params) {
31833183
}
31843184

31853185
var getSignHost = function (opt) {
3186-
if (!opt.Bucket || !opt.Bucket) return '';
3186+
if (!opt.Bucket || !opt.Region) return '';
3187+
var region = opt.Region;
3188+
if (this.options.UseAccelerate) {
3189+
region = 'accelerate';
3190+
}
31873191
var url = opt.Url || getUrl({
31883192
ForcePathStyle: this.options.ForcePathStyle,
31893193
protocol: this.options.Protocol,
31903194
domain: this.options.Domain,
31913195
bucket: opt.Bucket,
3192-
region: opt.Region,
3196+
region: region,
31933197
});
31943198
var urlHost = url.replace(/^https?:\/\/([^/]+)(\/.*)?$/, '$1');
31953199
var standardHostReg = new RegExp('^([a-z\\d-]+-\\d+\\.)?(cos|cosv6|ci|pic)\\.([a-z\\d-]+)\\.myqcloud\\.com$');
@@ -3200,7 +3204,6 @@ var getSignHost = function (opt) {
32003204

32013205
// 异步获取签名
32023206
function getAuthorizationAsync(params, callback) {
3203-
32043207
var headers = util.clone(params.Headers);
32053208
var headerHost = '';
32063209
util.each(headers, function (v, k) {

src/cos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ COS.util = {
7777
json2xml: util.json2xml,
7878
};
7979
COS.getAuthorization = util.getAuth;
80-
COS.version = '1.3.3';
80+
COS.version = '1.3.4';
8181

8282
module.exports = COS;

0 commit comments

Comments
 (0)