You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/ali-oss/lib/common/utils/setRegion.ts

16 lines
573 B

1 month ago
import urlutil from 'url';
import { checkConfigValid } from './checkConfigValid';
export function setRegion(region: string, internal = false, secure = false) {
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 urlutil.parse(protocol + region + suffix);
}