Skip to content

Commit ce5378c

Browse files
committed
优化 getSignHost 方法,判断 ci/pic 域名
1 parent f3e862b commit ce5378c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sdk/base.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,17 +3253,16 @@ function getUrl(params) {
32533253

32543254
var getSignHost = function (opt) {
32553255
if (!opt.Bucket || !opt.Bucket) return '';
3256-
var ps = this.options.ForcePathStyle;
32573256
var url = opt.Url || getUrl({
3258-
ForcePathStyle: ps,
3257+
ForcePathStyle: this.options.ForcePathStyle,
32593258
protocol: this.options.Protocol,
32603259
domain: this.options.Domain,
32613260
bucket: opt.Bucket,
32623261
region: opt.Region,
32633262
});
3264-
var standardHost = (ps ? '' : opt.Bucket + '.') + 'cos.' + opt.Region + '.myqcloud.com';
32653263
var urlHost = url.replace(/^https?:\/\/([^/]+)(\/.*)?$/, '$1');
3266-
if (standardHost === urlHost) return standardHost;
3264+
var standardHostReg = new RegExp('^([a-z\\d-]+-\\d+\\.)?(cos|cosv6|ci|pic)\\.([a-z\\d-]+)\\.myqcloud\\.com$');
3265+
if (standardHostReg.test(urlHost)) return urlHost;
32673266
return '';
32683267
}
32693268

0 commit comments

Comments
 (0)