Skip to content

Commit

Permalink
feat: support SecondLevelDomain (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyie authored and PeterRao committed Jan 13, 2020
1 parent e6b4ffe commit 1580167
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ proto._getReqUrl = function _getReqUrl(params) {
copy(this.options.endpoint).to(ep);
const isIP = this._isIP(ep.hostname);
const isCname = this.options.cname;
if (params.bucket && !isCname && !isIP) {
if (params.bucket && !isCname && !isIP && !this.options.sldEnable) {
ep.host = `${params.bucket}.${ep.host}`;
}

let resourcePath = '/';
if (params.bucket && isIP) {
if (params.bucket && (this.options.sldEnable || isIP)) {
resourcePath += `${params.bucket}/`;
}

Expand Down Expand Up @@ -461,3 +461,8 @@ proto.requestError = async function requestError(result) {
debug('generate error %j', err);
return err;
};

proto.setSLDEnabled = function setSLDEnabled(enable) {
this.options.sldEnable = !!enable;
return this;
};
3 changes: 2 additions & 1 deletion lib/common/client/initOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ module.exports = function (options) {
bucket: null,
endpoint: null,
cname: false,
isRequestPay: false
isRequestPay: false,
sldEnable: false
}, options);

opts.accessKeyId = opts.accessKeyId.trim();
Expand Down

0 comments on commit 1580167

Please sign in to comment.