vaderjs 1.0.8 → 1.0.9
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/package.json +1 -1
- package/vaderRouter.js +17 -8
package/package.json
CHANGED
package/vaderRouter.js
CHANGED
|
@@ -63,6 +63,7 @@ class VaderRouter {
|
|
|
63
63
|
* Starts the router.
|
|
64
64
|
*/
|
|
65
65
|
start() {
|
|
66
|
+
|
|
66
67
|
if (!this.routes[window.location.hash.substring(1)]) {
|
|
67
68
|
window.location.hash = this.starturl;
|
|
68
69
|
}
|
|
@@ -72,7 +73,12 @@ class VaderRouter {
|
|
|
72
73
|
: window.location.hash.substring(1);
|
|
73
74
|
// remove '' from array
|
|
74
75
|
hash = hash.filter((item) => item !== "");
|
|
75
|
-
|
|
76
|
+
let basePath = "";
|
|
77
|
+
if (hash.length > 1) {
|
|
78
|
+
basePath = hash[0] + "/" + hash[1];
|
|
79
|
+
} else {
|
|
80
|
+
basePath = hash[0];
|
|
81
|
+
}
|
|
76
82
|
|
|
77
83
|
if (!this.routes[basePath] && !this.customerror) {
|
|
78
84
|
window.location.hash = this.starturl;
|
|
@@ -313,19 +319,22 @@ class VaderRouter {
|
|
|
313
319
|
.join("/");
|
|
314
320
|
const regex = new RegExp("^" + parsedPath + "(\\?(.*))?$");
|
|
315
321
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
322
|
+
let hash = window.location.hash.split("#")[1]
|
|
323
|
+
? window.location.hash.split("#")[1]
|
|
324
|
+
: window.location.hash;
|
|
325
|
+
|
|
326
|
+
let basePath = "";
|
|
327
|
+
if (hash.length > 1) {
|
|
328
|
+
basePath = hash.split("/")[0] + "/" + hash.split("/")[1];
|
|
321
329
|
} else {
|
|
322
|
-
|
|
330
|
+
basePath = hash[0];
|
|
323
331
|
}
|
|
332
|
+
const route = basePath;
|
|
324
333
|
|
|
325
334
|
window.$CURRENT_URL = route;
|
|
326
335
|
window.$URL_PARAMS = {};
|
|
327
336
|
if (
|
|
328
|
-
|
|
337
|
+
window.location.hash.substring(1).match(regex) &&
|
|
329
338
|
this.routes[$CURRENT_URL]
|
|
330
339
|
) {
|
|
331
340
|
this.storedroutes.push(window.location.hash.substring(1));
|