@@ -1077,7 +1077,15 @@ class Router extends Framework7Class {
10771077 let initUrl = router . params . url ;
10781078 let documentUrl = document . location . href . split ( document . location . origin ) [ 1 ] ;
10791079 let historyRestored ;
1080- if ( ! router . params . pushState || ! router . params . pushStateOnLoad ) {
1080+ const { pushState, pushStateOnLoad, pushStateSeparator, pushStateAnimateOnLoad } = router . params ;
1081+ let { pushStateRoot } = router . params ;
1082+ if ( window . cordova && pushState && ! pushStateSeparator && ! pushStateRoot && document . location . pathname . indexOf ( 'index.html' ) ) {
1083+ // eslint-disable-next-line
1084+ console . warn ( 'Framework7: wrong or not complete pushState configuration, trying to guess pushStateRoot' ) ;
1085+ pushStateRoot = document . location . pathname . split ( 'index.html' ) [ 0 ] ;
1086+ }
1087+
1088+ if ( ! pushState || ! pushStateOnLoad ) {
10811089 if ( ! initUrl ) {
10821090 initUrl = documentUrl ;
10831091 }
@@ -1088,12 +1096,12 @@ class Router extends Framework7Class {
10881096 initUrl += document . location . hash ;
10891097 }
10901098 } else {
1091- if ( router . params . pushStateRoot && documentUrl . indexOf ( router . params . pushStateRoot ) >= 0 ) {
1092- documentUrl = documentUrl . split ( router . params . pushStateRoot ) [ 1 ] ;
1099+ if ( pushStateRoot && documentUrl . indexOf ( pushStateRoot ) >= 0 ) {
1100+ documentUrl = documentUrl . split ( pushStateRoot ) [ 1 ] ;
10931101 if ( documentUrl === '' ) documentUrl = '/' ;
10941102 }
1095- if ( router . params . pushStateSeparator . length > 0 && documentUrl . indexOf ( router . params . pushStateSeparator ) >= 0 ) {
1096- initUrl = documentUrl . split ( router . params . pushStateSeparator ) [ 1 ] ;
1103+ if ( pushStateSeparator . length > 0 && documentUrl . indexOf ( pushStateSeparator ) >= 0 ) {
1104+ initUrl = documentUrl . split ( pushStateSeparator ) [ 1 ] ;
10971105 } else {
10981106 initUrl = documentUrl ;
10991107 }
@@ -1105,7 +1113,7 @@ class Router extends Framework7Class {
11051113 } else if ( History . state && History . state [ view . id ] && History . state [ view . id ] . url === router . history [ router . history . length - 1 ] ) {
11061114 initUrl = router . history [ router . history . length - 1 ] ;
11071115 } else {
1108- router . history = [ documentUrl . split ( router . params . pushStateSeparator ) [ 0 ] || '/' , initUrl ] ;
1116+ router . history = [ documentUrl . split ( pushStateSeparator ) [ 0 ] || '/' , initUrl ] ;
11091117 }
11101118 if ( router . history . length > 1 ) {
11111119 historyRestored = true ;
@@ -1201,7 +1209,7 @@ class Router extends Framework7Class {
12011209 initial : true ,
12021210 pushState : false ,
12031211 history : false ,
1204- animate : router . params . pushStateAnimateOnLoad ,
1212+ animate : pushStateAnimateOnLoad ,
12051213 once : {
12061214 pageAfterIn ( ) {
12071215 if ( router . history . length > 2 ) {
@@ -1216,7 +1224,7 @@ class Router extends Framework7Class {
12161224 router . saveHistory ( ) ;
12171225 }
12181226 }
1219- if ( initUrl && router . params . pushState && router . params . pushStateOnLoad && ( ! History . state || ! History . state [ view . id ] ) ) {
1227+ if ( initUrl && pushState && pushStateOnLoad && ( ! History . state || ! History . state [ view . id ] ) ) {
12201228 History . initViewState ( view . id , {
12211229 url : initUrl ,
12221230 } ) ;
0 commit comments