@symbo.ls/router 2.11.34 → 2.11.38
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/index.js +10 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { setCookie } from '@domql/cookie'
|
|
4
4
|
import { redirectBasedOnAuth } from '@symbo.ls/auth-redirect'
|
|
5
|
-
import { findModal } from '@symbo.ls/modals/action'
|
|
6
5
|
|
|
7
6
|
export const getActiveRoute = (level = 0, route = window.location.pathname) => {
|
|
8
7
|
const routeArray = route.split('/')
|
|
@@ -21,6 +20,7 @@ const defaultOptions = {
|
|
|
21
20
|
scrollToNode: false,
|
|
22
21
|
scrollDocument: false,
|
|
23
22
|
useFragment: false,
|
|
23
|
+
authCheck: true,
|
|
24
24
|
updateState: true,
|
|
25
25
|
scrollToOffset: 120,
|
|
26
26
|
scrollToOptions: { behavior: 'smooth' }
|
|
@@ -39,10 +39,12 @@ export const router = (
|
|
|
39
39
|
const routeArray = pathname.split('/')
|
|
40
40
|
const rootRoute = getActiveRoute(0, path)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
if (options.authCheck) {
|
|
43
|
+
const authRedirect = redirectBasedOnAuth(rootRoute, element, element.state)
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (authRedirect && rootRoute !== authRedirect) {
|
|
46
|
+
routeArray[1] = authRedirect.slice(1)
|
|
47
|
+
}
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
const route = routeArray.join('/').replace('//', '/')
|
|
@@ -50,7 +52,10 @@ export const router = (
|
|
|
50
52
|
|
|
51
53
|
const content = element.routes[routeInContent] || element.routes['/*']
|
|
52
54
|
|
|
53
|
-
const
|
|
55
|
+
const { context } = element
|
|
56
|
+
const { modals } = context
|
|
57
|
+
console.log(modals)
|
|
58
|
+
const isModal = modals && (modals.findModal(element, element.state) || {}).FoundModal
|
|
54
59
|
const isInitial = options.initialRender
|
|
55
60
|
const hashChanged = hash && hash !== window.location.hash.slice(1)
|
|
56
61
|
const pathChanged = pathname !== lastPathname
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/router",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.38",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"@domql/utils": "latest",
|
|
12
12
|
"@symbo.ls/auth-redirect": "latest"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "0fe21ad13a7b9059e01ddacb0fa49e3b57542684",
|
|
15
15
|
"source": "index.js"
|
|
16
16
|
}
|