@@ -7,34 +7,9 @@ const debug = makeDebugger('L:Route')
77/* eslint-enable no-unused-vars */
88
99let route = null
10+ const INDEX = ''
1011
11- /*
12- const getAsPathList = R.compose(
13- R.reject(R.isEmpty),
14- R.split('/'),
15- R.prop('asPath')
16- )
17-
18- const getQueryMain = routeObj => {
19- if (R.isEmpty(routeObj)) return ''
20-
21- if (isEmptyNil(routeObj.query) && routeObj.pathname !== '/') {
22- return routeObj.pathname.slice(1)
23- } else if (isEmptyNil(routeObj.query) && routeObj.pathname === '/') {
24- const asPathList = getAsPathList(routeObj)
25- return R.head(asPathList)
26- }
27-
28- return routeObj.query.main
29- }
30-
31- const getQuerySub = routeObj => {
32- const asPathList = getAsPathList(routeObj)
33- return R.last(asPathList)
34- }
35- */
36-
37- const asPathForMain = R . compose (
12+ const parseMainPath = R . compose (
3813 R . head ,
3914 R . split ( '?' ) ,
4015 R . head ,
@@ -43,21 +18,7 @@ const asPathForMain = R.compose(
4318 R . prop ( 'asPath' )
4419)
4520
46- const INDEX = ''
47- const getMainPath = routeObj => {
48- if ( R . isEmpty ( routeObj ) ) return INDEX
49- const { asPath } = routeObj
50- if ( asPath === '/' ) return INDEX
51-
52- /* const test = splitAsPathTest('/communities/posts/?page=1&size=20') */
53- /* console.log('test --> ', test) */
54-
55- /* const asPathList = splitAsPath(routeObj) */
56- /* console.log('asPathList -- > ', asPathList) */
57- return asPathForMain ( routeObj )
58- }
59-
60- const asPathForSub = R . compose (
21+ const parseSubPathList = R . compose (
6122 R . reject ( R . isEmpty ) ,
6223 R . split ( '/' ) ,
6324 R . head ,
@@ -67,34 +28,25 @@ const asPathForSub = R.compose(
6728 R . prop ( 'asPath' )
6829)
6930
70- const getSubPath = routeObj => {
31+ const getMainPath = routeObj => {
7132 if ( R . isEmpty ( routeObj ) ) return INDEX
33+ if ( routeObj . asPath === '/' ) return INDEX
7234
73- const { asPath } = routeObj
74- if ( asPath === '/' ) return INDEX
35+ return parseMainPath ( routeObj )
36+ }
7537
76- const asPathList = asPathForSub ( routeObj )
77- /* console.log('asPath jjj -> ', asPathList) */
78- /* const asPathList = asPathForSub('/communities ') */
38+ const getSubPath = routeObj => {
39+ if ( R . isEmpty ( routeObj ) ) return INDEX
40+ if ( routeObj . asPath === '/ ') return INDEX
7941
80- /* const asPathList = asPathForSub('/communities/posts?page=2&size=20') */
81- /* const asPathListtest = asPathForSub('/communities/posts/?page=2&size=20') */
82- /* const asPathListtest = fuckmetest('/communities') */
83- /* const asPathListtest = fuckmetest('/communities/') */
84- /* console.log('asPathListtest jjj -> ', asPathListtest) */
42+ const asPathList = parseSubPathList ( routeObj )
8543
8644 return asPathList . length > 1 ? asPathList [ 1 ] : asPathList [ 0 ]
8745}
8846
8947export function syncRoute ( routeObj ) {
90- /* const mainQuery = getQueryMain(routeObj) */
9148 const mainQuery = getMainPath ( routeObj )
92- /* console.log('mainQuery ## ', mainQuery) */
93-
9449 const subQuery = getSubPath ( routeObj )
95- /* const subQuery = getSubPath(routeObj) */
96- /* const subPath = getSubPath(routeObj) */
97- /* console.log('subPath final --> ', subPath) */
9850
9951 const { query } = routeObj
10052
0 commit comments