@cabloy/module-info 1.0.12 → 1.0.13
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -10
- package/dist/interface.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './interface.js';
|
|
|
3
3
|
export declare function parseInfoFromPath(pathName?: string | null): IModuleInfo | undefined;
|
|
4
4
|
export declare function parseInfo(moduleName: string | undefined): IModuleInfo | undefined;
|
|
5
5
|
export declare function parseInfoPro(moduleName: string | undefined, projectMode: TypeProjectMode, projectEntityType: TypeProjectEntityType): IModuleInfo | undefined;
|
|
6
|
-
export declare function parseName(moduleUrl: any):
|
|
6
|
+
export declare function parseName(moduleUrl: any): string | undefined;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const PREFIX_A = '/api/';
|
|
|
36
36
|
const PREFIX_B = 'cabloy-module-api-';
|
|
37
37
|
const PREFIX_C = './cabloy-module-api-';
|
|
38
38
|
const PREFIX_D = './';
|
|
39
|
+
const PREFIX_E = '/';
|
|
39
40
|
// aa-hello aa/hello
|
|
40
41
|
// first check / then -
|
|
41
42
|
function parseInfo(moduleName) {
|
|
@@ -77,19 +78,12 @@ exports.parseInfoPro = parseInfoPro;
|
|
|
77
78
|
// ./cabloy-module-api-aa-hello/
|
|
78
79
|
function parseName(moduleUrl) {
|
|
79
80
|
if (!moduleUrl)
|
|
80
|
-
return
|
|
81
|
+
return;
|
|
81
82
|
if (moduleUrl.indexOf('/api/static/') === 0) {
|
|
82
83
|
moduleUrl = '/api/' + moduleUrl.substring('/api/static/'.length);
|
|
83
84
|
}
|
|
84
85
|
if (moduleUrl.indexOf(PREFIX_A) === 0) {
|
|
85
|
-
|
|
86
|
-
const posB = moduleUrl.indexOf('/', posA) + 1;
|
|
87
|
-
if (posB === -1)
|
|
88
|
-
return null;
|
|
89
|
-
const posC = moduleUrl.indexOf('/', posB);
|
|
90
|
-
if (posC === -1)
|
|
91
|
-
return null;
|
|
92
|
-
return moduleUrl.substring(posA, posC);
|
|
86
|
+
return _parseNameLikeUrl(moduleUrl, PREFIX_A);
|
|
93
87
|
}
|
|
94
88
|
else if (moduleUrl.indexOf(PREFIX_B) === 0) {
|
|
95
89
|
return _parseName(moduleUrl, PREFIX_B);
|
|
@@ -100,12 +94,32 @@ function parseName(moduleUrl) {
|
|
|
100
94
|
else if (moduleUrl.indexOf(PREFIX_D) === 0) {
|
|
101
95
|
return _parseName(moduleUrl, PREFIX_D);
|
|
102
96
|
}
|
|
103
|
-
|
|
97
|
+
else if (moduleUrl.indexOf(PREFIX_E) === 0) {
|
|
98
|
+
return _parseNameLikeUrl(moduleUrl, PREFIX_E);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// test-home test/home
|
|
102
|
+
return _parseName(moduleUrl.replace('/', '-'), '');
|
|
103
|
+
}
|
|
104
104
|
}
|
|
105
105
|
exports.parseName = parseName;
|
|
106
|
+
function _parseNameLikeUrl(moduleUrl, prefix) {
|
|
107
|
+
const posA = prefix.length;
|
|
108
|
+
const posB = moduleUrl.indexOf('/', posA) + 1;
|
|
109
|
+
if (posB === -1)
|
|
110
|
+
return;
|
|
111
|
+
const posC = moduleUrl.indexOf('/', posB);
|
|
112
|
+
if (posC === -1)
|
|
113
|
+
return;
|
|
114
|
+
return moduleUrl.substring(posA, posC).replace('/', '-');
|
|
115
|
+
}
|
|
106
116
|
function _parseName(moduleUrl, prefix) {
|
|
107
117
|
const posA = prefix.length;
|
|
108
118
|
let posB = moduleUrl.indexOf('/', posA);
|
|
119
|
+
if (posB === -1)
|
|
120
|
+
posB = moduleUrl.indexOf(':', posA);
|
|
121
|
+
if (posB === -1)
|
|
122
|
+
posB = moduleUrl.indexOf('.', posA);
|
|
109
123
|
if (posB === -1)
|
|
110
124
|
posB = moduleUrl.length;
|
|
111
125
|
return moduleUrl.substring(posA, posB);
|
package/dist/interface.d.ts
CHANGED