hexo/node_modules/ali-oss/lib/common/utils/setRegion.js

21 lines
919 B
JavaScript
Raw Normal View History

2023-10-03 11:14:36 +08:00
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setRegion = void 0;
const url_1 = __importDefault(require("url"));
const checkConfigValid_1 = require("./checkConfigValid");
function setRegion(region, internal = false, secure = false) {
checkConfigValid_1.checkConfigValid(region, 'region');
const protocol = secure ? 'https://' : 'http://';
let suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
const prefix = 'vpc100-oss-cn-';
// aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
if (region.substr(0, prefix.length) === prefix) {
suffix = '.aliyuncs.com';
}
return url_1.default.parse(protocol + region + suffix);
}
exports.setRegion = setRegion;