Skip to content

Commit 1580167

Browse files
weiyiePeterRao
authored andcommitted
feat: support SecondLevelDomain (#729)
1 parent e6b4ffe commit 1580167

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/client.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ proto._getReqUrl = function _getReqUrl(params) {
296296
copy(this.options.endpoint).to(ep);
297297
const isIP = this._isIP(ep.hostname);
298298
const isCname = this.options.cname;
299-
if (params.bucket && !isCname && !isIP) {
299+
if (params.bucket && !isCname && !isIP && !this.options.sldEnable) {
300300
ep.host = `${params.bucket}.${ep.host}`;
301301
}
302302

303303
let resourcePath = '/';
304-
if (params.bucket && isIP) {
304+
if (params.bucket && (this.options.sldEnable || isIP)) {
305305
resourcePath += `${params.bucket}/`;
306306
}
307307

@@ -461,3 +461,8 @@ proto.requestError = async function requestError(result) {
461461
debug('generate error %j', err);
462462
return err;
463463
};
464+
465+
proto.setSLDEnabled = function setSLDEnabled(enable) {
466+
this.options.sldEnable = !!enable;
467+
return this;
468+
};

lib/common/client/initOptions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ module.exports = function (options) {
4646
bucket: null,
4747
endpoint: null,
4848
cname: false,
49-
isRequestPay: false
49+
isRequestPay: false,
50+
sldEnable: false
5051
}, options);
5152

5253
opts.accessKeyId = opts.accessKeyId.trim();

0 commit comments

Comments
 (0)