@alicloud/alfa-core 1.5.0-alpha.4 → 1.5.0-alpha.6
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.
|
@@ -12,22 +12,24 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
var currentCdnHost = getCurrentCdnHost();
|
|
15
16
|
export default function requestInterceptor(_x) {
|
|
16
17
|
return _requestInterceptor.apply(this, arguments);
|
|
17
18
|
}
|
|
18
19
|
function _requestInterceptor() {
|
|
19
20
|
_requestInterceptor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(config) {
|
|
20
|
-
var hostname;
|
|
21
21
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (currentCdnHost !== 'alicdn.com') {
|
|
25
|
+
// if cdn is not alicdn, replace it
|
|
26
|
+
if (currentCdnHost && config.url) {
|
|
27
|
+
// 非公有云下无 cws2
|
|
28
|
+
config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.');
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
return _context.abrupt("return", config);
|
|
30
|
-
case
|
|
32
|
+
case 2:
|
|
31
33
|
case "end":
|
|
32
34
|
return _context.stop();
|
|
33
35
|
}
|
|
@@ -19,22 +19,24 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
|
19
19
|
return undefined;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
var currentCdnHost = getCurrentCdnHost();
|
|
22
23
|
function requestInterceptor(_x) {
|
|
23
24
|
return _requestInterceptor.apply(this, arguments);
|
|
24
25
|
}
|
|
25
26
|
function _requestInterceptor() {
|
|
26
27
|
_requestInterceptor = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(config) {
|
|
27
|
-
var hostname;
|
|
28
28
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
29
29
|
while (1) switch (_context.prev = _context.next) {
|
|
30
30
|
case 0:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
if (currentCdnHost !== 'alicdn.com') {
|
|
32
|
+
// if cdn is not alicdn, replace it
|
|
33
|
+
if (currentCdnHost && config.url) {
|
|
34
|
+
// 非公有云下无 cws2
|
|
35
|
+
config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.');
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
return _context.abrupt("return", config);
|
|
37
|
-
case
|
|
39
|
+
case 2:
|
|
38
40
|
case "end":
|
|
39
41
|
return _context.stop();
|
|
40
42
|
}
|