租房小程序前端代码
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.

15 lines
573 B

3 months ago
  1. import urlutil from 'url';
  2. import { checkConfigValid } from './checkConfigValid';
  3. export function setRegion(region: string, internal = false, secure = false) {
  4. checkConfigValid(region, 'region');
  5. const protocol = secure ? 'https://' : 'http://';
  6. let suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
  7. const prefix = 'vpc100-oss-cn-';
  8. // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
  9. if (region.substr(0, prefix.length) === prefix) {
  10. suffix = '.aliyuncs.com';
  11. }
  12. return urlutil.parse(protocol + region + suffix);
  13. }