File tree Expand file tree Collapse file tree 1 file changed +9
-18
lines changed Expand file tree Collapse file tree 1 file changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -7,26 +7,17 @@ export function itemToLinks(items) {
77}
88
99function createLink ( item ) {
10- if ( typeof ( item ) === 'string' && item . includes ( API_PATH ) > 0 ) {
11- let route = null ;
12- const routeTest = item . replace ( API_PATH , '' ) ;
13- if ( routeTest [ 0 ] === '/' ) {
14- route = item . replace ( API_PATH , '' ) . split ( '/' ) [ 1 ] ;
15- } else {
16- route = item . replace ( API_PATH , '' ) . split ( '/' ) [ 0 ] ;
17- }
18- return (
19- < span key = { item } >
20- < Link to = { `/${ route } /show/${ encodeURIComponent ( item ) } ` } >
21- { item }
22- </ Link >
23- < br />
24- </ span >
25- ) ;
10+ if ( 'string' !== typeof ( item ) || ! item . includes ( API_PATH ) ) {
11+ return < span key = { item } > { item } < br /> </ span > ;
2612 }
27- return < span key = { item } > { item } < br /> </ span > ;
13+
14+ const routeWithoutPrefix = item . replace ( API_PATH , '' ) ;
15+ const splittedRoute = routeWithoutPrefix . split ( '/' ) ;
16+ const route = '/' === routeWithoutPrefix [ 0 ] ? splittedRoute [ 1 ] : splittedRoute [ 0 ] ;
17+
18+ return < span > < Link key = { item } to = { `/${ route } /show/${ encodeURIComponent ( item ) } ` } > { item } </ Link > < br /> </ span > ;
2819}
2920
3021export function paginationRoute ( item ) {
31- return '/' + item . split ( '/' ) . splice ( - 1 , 1 ) ;
22+ return '/' + item . split ( '/' ) . splice ( - 1 , 1 ) ;
3223}
You can’t perform that action at this time.
0 commit comments