1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DefaultTypeNameConvertor = function (id) {
|
4 | var url = id.id;
|
5 | var ids = [];
|
6 | if (url.host) {
|
7 | ids.push(decodeURIComponent(url.host));
|
8 | }
|
9 | var addAllParts = function (path) {
|
10 | var paths = path.split('/');
|
11 | if (paths.length > 1 && paths[0] === '') {
|
12 | paths.shift();
|
13 | }
|
14 | paths.forEach(function (item) {
|
15 | ids.push(decodeURIComponent(item));
|
16 | });
|
17 | };
|
18 | if (url.pathname) {
|
19 | addAllParts(url.pathname);
|
20 | }
|
21 | if (url.hash && url.hash.length > 1) {
|
22 | addAllParts(url.hash.substr(1));
|
23 | }
|
24 | return ids.map(toTypeName);
|
25 | };
|
26 | function toTypeName(str) {
|
27 | if (!str) {
|
28 | return str;
|
29 | }
|
30 | var result = str.trim().split('$').map(function (s) { return s.replace(/(?:^|[^A-Za-z0-9])([A-Za-z0-9]|$)/g, function (_, m) {
|
31 | return m.toUpperCase();
|
32 | }); }).join('$');
|
33 | return result;
|
34 | }
|
35 | function normalizeTypeName(type) {
|
36 | type = type.replace(/^\//, '').replace(/[^0-9A-Za-z_$]+/g, '_');
|
37 | if (/^\d/.test(type)) {
|
38 | type = '$' + type;
|
39 | }
|
40 | return type;
|
41 | }
|
42 | exports.normalizeTypeName = normalizeTypeName;
|
43 |
|
\ | No newline at end of file |