Assign image keyname and pubkey at vnf level
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / help / help-module / src / main / resources / help / help.utilities.ts
1 export var resolvePath = function (...paths: string[]): string {
2   console.log(paths);
3   function resolve(pathA, pathB) {
4     //  ‘a’     => ['a']
5     //  'a/b'   => ['a', 'b']
6     //  '/a/b'  => ['', 'a', 'b']
7     //  '/a/b/' => ['', 'a', 'b', '']
8     pathB = pathB.split('/');
9     if (pathB[0] === '') {
10       return pathB.join('/');
11     }
12     pathA = pathA.split('/');
13     var aLastIndex = pathA.length - 1;
14     if (pathA[aLastIndex] !== '') {
15       pathA[aLastIndex] = '';
16     }
17
18     var part;
19     var i = 0;
20     while (typeof (part = pathB[i]) === 'string') {
21       switch (part) {
22         case '..':
23           pathA.pop();
24           pathA.pop();
25           pathA.push('');
26           break;
27         case '.':
28           pathA.pop();
29           pathA.push('');
30           break;
31         default:
32           pathA.pop();
33           pathA.push(part);
34           pathA.push('');
35           break;
36       }
37       i++;
38     }
39     if (pathB[pathB.length - 1] !== '') pathA.pop(); 
40     return pathA.join('/');
41   }
42
43   var i = 0;
44   var path;
45   var r = location.pathname;
46
47   const urlRegex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i;
48   const multiSlashReg = /\/\/+/g;
49
50   while (typeof (path = paths[i]) === 'string') {
51     // debugger;
52     const matches = path && path.match(urlRegex);
53     if (matches || !i) {
54       r = path;
55     } else {
56       path = path.replace(multiSlashReg, '/');
57       r = resolve(r, path);
58     }
59     i++;
60   }
61
62   return r;
63 };