@alicloud/alfa-core 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
|
|
4
|
+
|
|
3
5
|
// 兼容非公有云环境
|
|
4
6
|
var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
5
7
|
try {
|
|
@@ -13,6 +15,8 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
|
13
15
|
}
|
|
14
16
|
};
|
|
15
17
|
var currentCdnHost = getCurrentCdnHost();
|
|
18
|
+
|
|
19
|
+
// 根据不同环境替换 cdn 的域名
|
|
16
20
|
export default function requestInterceptor(_x) {
|
|
17
21
|
return _requestInterceptor.apply(this, arguments);
|
|
18
22
|
}
|
|
@@ -21,9 +25,9 @@ function _requestInterceptor() {
|
|
|
21
25
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
26
|
while (1) switch (_context.prev = _context.next) {
|
|
23
27
|
case 0:
|
|
24
|
-
if (currentCdnHost !== 'alicdn.com') {
|
|
28
|
+
if (currentCdnHost && currentCdnHost !== 'alicdn.com' && whiteList.includes(currentCdnHost)) {
|
|
25
29
|
// if cdn is not alicdn, replace it
|
|
26
|
-
if (
|
|
30
|
+
if (config.url) {
|
|
27
31
|
config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.') // 非公有云下无 cws2
|
|
28
32
|
.replace('dev.g.idptcloud01cdn.com', 'dev-g.idptcloud01cdn.com'); // idptcloud01cdn 无 dev.g 子域名
|
|
29
33
|
}
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = requestInterceptor;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
|
|
11
|
+
|
|
10
12
|
// 兼容非公有云环境
|
|
11
13
|
var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
12
14
|
try {
|
|
@@ -20,6 +22,8 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
var currentCdnHost = getCurrentCdnHost();
|
|
25
|
+
|
|
26
|
+
// 根据不同环境替换 cdn 的域名
|
|
23
27
|
function requestInterceptor(_x) {
|
|
24
28
|
return _requestInterceptor.apply(this, arguments);
|
|
25
29
|
}
|
|
@@ -28,9 +32,9 @@ function _requestInterceptor() {
|
|
|
28
32
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
29
33
|
while (1) switch (_context.prev = _context.next) {
|
|
30
34
|
case 0:
|
|
31
|
-
if (currentCdnHost !== 'alicdn.com') {
|
|
35
|
+
if (currentCdnHost && currentCdnHost !== 'alicdn.com' && whiteList.includes(currentCdnHost)) {
|
|
32
36
|
// if cdn is not alicdn, replace it
|
|
33
|
-
if (
|
|
37
|
+
if (config.url) {
|
|
34
38
|
config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.') // 非公有云下无 cws2
|
|
35
39
|
.replace('dev.g.idptcloud01cdn.com', 'dev-g.idptcloud01cdn.com'); // idptcloud01cdn 无 dev.g 子域名
|
|
36
40
|
}
|