@alicloud/alfa-core 1.4.34 → 1.4.36

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.
@@ -7,7 +7,12 @@ import { getRelativePath, getFeatureStatus } from './index';
7
7
  var formatURL = function formatURL(origin, base) {
8
8
  // incorrect: new URL('../b', 'https://example.com/a/c') => https://example.com/b
9
9
  // correct: new URL('../b', 'https://example.com/a/c/') => https://example.com/a/b
10
- return new URL(origin, base.endsWith('/') ? base : "".concat(base, "/")).toString();
10
+ try {
11
+ return new URL(origin, base.endsWith('/') ? base : "".concat(base, "/")).toString();
12
+ } catch (e) {
13
+ // base maybe not legal
14
+ return origin;
15
+ }
11
16
  };
12
17
 
13
18
  /**
package/es/utils/index.js CHANGED
@@ -68,28 +68,32 @@ function trimArray(arr) {
68
68
  * @returns
69
69
  */
70
70
  export var getRelativePath = function getRelativePath(from, to, base) {
71
- var _URL = new URL(from, base || from),
72
- fromHost = _URL.host,
73
- fromPath = _URL.pathname;
74
- var _URL2 = new URL(to, base || from),
75
- toHost = _URL2.host,
76
- toPath = _URL2.pathname;
71
+ try {
72
+ var _URL = new URL(from, base || from),
73
+ fromHost = _URL.host,
74
+ fromPath = _URL.pathname;
75
+ var _URL2 = new URL(to, base || from),
76
+ toHost = _URL2.host,
77
+ toPath = _URL2.pathname;
77
78
 
78
- // from 'g.alicdn.com' to 'dev.g.alicdn.com' regarded as same host
79
- if (fromHost !== toHost && (toHost !== 'g.alicdn.com' || fromHost !== 'dev.g.alicdn.com')) return to;
80
- var fromParts = trimArray(fromPath.split('/'));
81
- var toParts = trimArray(toPath.split('/'));
82
- var length = Math.min(fromParts.length, toParts.length);
83
- var samePartsLength = length;
84
- for (var i = 0; i < length; i++) {
85
- if (fromParts[i] !== toParts[i]) {
86
- samePartsLength = i;
87
- break;
79
+ // from 'g.alicdn.com' to 'dev.g.alicdn.com' regarded as same host
80
+ if (fromHost !== toHost && (toHost !== 'g.alicdn.com' || fromHost !== 'dev.g.alicdn.com')) return to;
81
+ var fromParts = trimArray(fromPath.split('/'));
82
+ var toParts = trimArray(toPath.split('/'));
83
+ var length = Math.min(fromParts.length, toParts.length);
84
+ var samePartsLength = length;
85
+ for (var i = 0; i < length; i++) {
86
+ if (fromParts[i] !== toParts[i]) {
87
+ samePartsLength = i;
88
+ break;
89
+ }
88
90
  }
91
+ var outputParts = [];
92
+ for (var _i = samePartsLength; _i < fromParts.length; _i++) {
93
+ outputParts.push('..');
94
+ }
95
+ return outputParts.concat(toParts.slice(samePartsLength)).join('/');
96
+ } catch (e) {
97
+ return to;
89
98
  }
90
- var outputParts = [];
91
- for (var _i = samePartsLength; _i < fromParts.length; _i++) {
92
- outputParts.push('..');
93
- }
94
- return outputParts.concat(toParts.slice(samePartsLength)).join('/');
95
99
  };
@@ -14,7 +14,12 @@ var _index = require("./index");
14
14
  var formatURL = function formatURL(origin, base) {
15
15
  // incorrect: new URL('../b', 'https://example.com/a/c') => https://example.com/b
16
16
  // correct: new URL('../b', 'https://example.com/a/c/') => https://example.com/a/b
17
- return new URL(origin, base.endsWith('/') ? base : "".concat(base, "/")).toString();
17
+ try {
18
+ return new URL(origin, base.endsWith('/') ? base : "".concat(base, "/")).toString();
19
+ } catch (e) {
20
+ // base maybe not legal
21
+ return origin;
22
+ }
18
23
  };
19
24
 
20
25
  /**
@@ -90,29 +90,33 @@ function trimArray(arr) {
90
90
  * @returns
91
91
  */
92
92
  var getRelativePath = function getRelativePath(from, to, base) {
93
- var _URL = new URL(from, base || from),
94
- fromHost = _URL.host,
95
- fromPath = _URL.pathname;
96
- var _URL2 = new URL(to, base || from),
97
- toHost = _URL2.host,
98
- toPath = _URL2.pathname;
93
+ try {
94
+ var _URL = new URL(from, base || from),
95
+ fromHost = _URL.host,
96
+ fromPath = _URL.pathname;
97
+ var _URL2 = new URL(to, base || from),
98
+ toHost = _URL2.host,
99
+ toPath = _URL2.pathname;
99
100
 
100
- // from 'g.alicdn.com' to 'dev.g.alicdn.com' regarded as same host
101
- if (fromHost !== toHost && (toHost !== 'g.alicdn.com' || fromHost !== 'dev.g.alicdn.com')) return to;
102
- var fromParts = trimArray(fromPath.split('/'));
103
- var toParts = trimArray(toPath.split('/'));
104
- var length = Math.min(fromParts.length, toParts.length);
105
- var samePartsLength = length;
106
- for (var i = 0; i < length; i++) {
107
- if (fromParts[i] !== toParts[i]) {
108
- samePartsLength = i;
109
- break;
101
+ // from 'g.alicdn.com' to 'dev.g.alicdn.com' regarded as same host
102
+ if (fromHost !== toHost && (toHost !== 'g.alicdn.com' || fromHost !== 'dev.g.alicdn.com')) return to;
103
+ var fromParts = trimArray(fromPath.split('/'));
104
+ var toParts = trimArray(toPath.split('/'));
105
+ var length = Math.min(fromParts.length, toParts.length);
106
+ var samePartsLength = length;
107
+ for (var i = 0; i < length; i++) {
108
+ if (fromParts[i] !== toParts[i]) {
109
+ samePartsLength = i;
110
+ break;
111
+ }
110
112
  }
113
+ var outputParts = [];
114
+ for (var _i = samePartsLength; _i < fromParts.length; _i++) {
115
+ outputParts.push('..');
116
+ }
117
+ return outputParts.concat(toParts.slice(samePartsLength)).join('/');
118
+ } catch (e) {
119
+ return to;
111
120
  }
112
- var outputParts = [];
113
- for (var _i = samePartsLength; _i < fromParts.length; _i++) {
114
- outputParts.push('..');
115
- }
116
- return outputParts.concat(toParts.slice(samePartsLength)).join('/');
117
121
  };
118
122
  exports.getRelativePath = getRelativePath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-core",
3
- "version": "1.4.34",
3
+ "version": "1.4.36",
4
4
  "description": "MicroFront End SDK for alicloud",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -28,7 +28,7 @@
28
28
  "axios": "^0.21.4",
29
29
  "crypto-js": "^4.1.1",
30
30
  "tslib": "^2.4.0",
31
- "@alicloud/console-os-kernal": "^1.4.35-alpha.0"
31
+ "@alicloud/console-os-kernal": "^1.4.37"
32
32
  },
33
33
  "gitHead": "6387c6b9e984da70641716a25ff92d382cc4d7ca",
34
34
  "scripts": {