@alicloud/alfa-core 1.5.3 → 1.5.4
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,15 +1,26 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
|
|
4
|
+
var win = window;
|
|
4
5
|
|
|
5
6
|
// 兼容非公有云环境
|
|
6
7
|
var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
7
8
|
try {
|
|
8
9
|
var _document$currentScri;
|
|
10
|
+
// 逻辑上所有的微应用 cdn 都是同一个 host,所以可以复用同一个全局变量
|
|
11
|
+
if (win.__alfa_cdn_host__) {
|
|
12
|
+
return win.__alfa_cdn_host__;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// document.currentScript 可能为 null
|
|
9
16
|
var _URL = new URL(((_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src) || ''),
|
|
10
17
|
hostname = _URL.hostname;
|
|
11
18
|
var parts = hostname.split('.');
|
|
12
|
-
|
|
19
|
+
var _currentCdnHost = parts.length > 2 ? parts.slice(-2).join('.') : hostname;
|
|
20
|
+
if (!win.__alfa_cdn_host__) {
|
|
21
|
+
win.__alfa_cdn_host__ = _currentCdnHost;
|
|
22
|
+
}
|
|
23
|
+
return _currentCdnHost;
|
|
13
24
|
} catch (e) {
|
|
14
25
|
return undefined;
|
|
15
26
|
}
|
|
@@ -8,15 +8,26 @@ exports.default = requestInterceptor;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
|
|
11
|
+
var win = window;
|
|
11
12
|
|
|
12
13
|
// 兼容非公有云环境
|
|
13
14
|
var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
14
15
|
try {
|
|
15
16
|
var _document$currentScri;
|
|
17
|
+
// 逻辑上所有的微应用 cdn 都是同一个 host,所以可以复用同一个全局变量
|
|
18
|
+
if (win.__alfa_cdn_host__) {
|
|
19
|
+
return win.__alfa_cdn_host__;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// document.currentScript 可能为 null
|
|
16
23
|
var _URL = new URL(((_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src) || ''),
|
|
17
24
|
hostname = _URL.hostname;
|
|
18
25
|
var parts = hostname.split('.');
|
|
19
|
-
|
|
26
|
+
var _currentCdnHost = parts.length > 2 ? parts.slice(-2).join('.') : hostname;
|
|
27
|
+
if (!win.__alfa_cdn_host__) {
|
|
28
|
+
win.__alfa_cdn_host__ = _currentCdnHost;
|
|
29
|
+
}
|
|
30
|
+
return _currentCdnHost;
|
|
20
31
|
} catch (e) {
|
|
21
32
|
return undefined;
|
|
22
33
|
}
|