@atolis-hq/corum 0.1.0 → 0.1.6

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/web/router.js CHANGED
@@ -1,49 +1,49 @@
1
- (function () {
2
- 'use strict';
3
-
4
- var KNOWN_PATHS = new Set(['/dashboard', '/components', '/node']);
5
-
6
- function parseRoute(hash) {
7
- var raw = (hash || '').replace(/^#/, '') || '/dashboard';
8
- var qIndex = raw.indexOf('?');
9
- var pathPart = qIndex === -1 ? raw : raw.slice(0, qIndex);
10
- var search = qIndex === -1 ? '' : raw.slice(qIndex + 1);
11
- var params = new URLSearchParams(search);
12
- var segments = pathPart.split('/').filter(Boolean);
13
-
14
- if (segments.length === 0) {
15
- return { branch: null, pathname: '/dashboard', params: params };
16
- }
17
-
18
- var firstDecoded = decodeURIComponent(segments[0]);
19
- var firstAsPath = '/' + firstDecoded;
20
-
21
- if (KNOWN_PATHS.has(firstAsPath)) {
22
- return { branch: null, pathname: firstAsPath, params: params };
23
- }
24
-
25
- var branch = firstDecoded;
26
- var pathname = segments[1] ? '/' + decodeURIComponent(segments[1]) : '/dashboard';
27
- return { branch: branch, pathname: pathname, params: params };
28
- }
29
-
30
- function buildRoute(opts) {
31
- var pathname = opts.pathname;
32
- var params = opts.params || {};
33
- var branch = opts.branch || null;
34
- var qs = new URLSearchParams(params).toString();
35
- var suffix = qs ? '?' + qs : '';
36
- if (!branch) {
37
- return '#' + pathname + suffix;
38
- }
39
- var encodedBranch = encodeURIComponent(branch);
40
- return '#/' + encodedBranch + pathname + suffix;
41
- }
42
-
43
- if (typeof module !== 'undefined' && module.exports) {
44
- module.exports = { parseRoute: parseRoute, buildRoute: buildRoute };
45
- }
46
- if (typeof window !== 'undefined') {
47
- window.CorumRouter = { parseRoute: parseRoute, buildRoute: buildRoute };
48
- }
49
- }());
1
+ (function () {
2
+ 'use strict';
3
+
4
+ var KNOWN_PATHS = new Set(['/dashboard', '/components', '/node']);
5
+
6
+ function parseRoute(hash) {
7
+ var raw = (hash || '').replace(/^#/, '') || '/dashboard';
8
+ var qIndex = raw.indexOf('?');
9
+ var pathPart = qIndex === -1 ? raw : raw.slice(0, qIndex);
10
+ var search = qIndex === -1 ? '' : raw.slice(qIndex + 1);
11
+ var params = new URLSearchParams(search);
12
+ var segments = pathPart.split('/').filter(Boolean);
13
+
14
+ if (segments.length === 0) {
15
+ return { branch: null, pathname: '/dashboard', params: params };
16
+ }
17
+
18
+ var firstDecoded = decodeURIComponent(segments[0]);
19
+ var firstAsPath = '/' + firstDecoded;
20
+
21
+ if (KNOWN_PATHS.has(firstAsPath)) {
22
+ return { branch: null, pathname: firstAsPath, params: params };
23
+ }
24
+
25
+ var branch = firstDecoded;
26
+ var pathname = segments[1] ? '/' + decodeURIComponent(segments[1]) : '/dashboard';
27
+ return { branch: branch, pathname: pathname, params: params };
28
+ }
29
+
30
+ function buildRoute(opts) {
31
+ var pathname = opts.pathname;
32
+ var params = opts.params || {};
33
+ var branch = opts.branch || null;
34
+ var qs = new URLSearchParams(params).toString();
35
+ var suffix = qs ? '?' + qs : '';
36
+ if (!branch) {
37
+ return '#' + pathname + suffix;
38
+ }
39
+ var encodedBranch = encodeURIComponent(branch);
40
+ return '#/' + encodedBranch + pathname + suffix;
41
+ }
42
+
43
+ if (typeof module !== 'undefined' && module.exports) {
44
+ module.exports = { parseRoute: parseRoute, buildRoute: buildRoute };
45
+ }
46
+ if (typeof window !== 'undefined') {
47
+ window.CorumRouter = { parseRoute: parseRoute, buildRoute: buildRoute };
48
+ }
49
+ }());