@@ -35,12 +35,12 @@ app.Router = class Router extends Events {
3535 }
3636
3737 before ( context , next ) {
38- let res ;
3938 const previousContext = this . context ;
4039 this . context = context ;
4140 this . trigger ( "before" , context ) ;
4241
43- if ( ( res = next ( ) ) ) {
42+ const res = next ( ) ;
43+ if ( res ) {
4444 this . context = previousContext ;
4545 return res ;
4646 } else {
@@ -79,27 +79,29 @@ app.Router = class Router extends Events {
7979 }
8080
8181 entry ( context , next ) {
82- let entry ;
8382 const doc = app . docs . findBySlug ( context . params . doc ) ;
8483 if ( ! doc ) {
8584 return next ( ) ;
8685 }
8786 let { path } = context . params ;
8887 const { hash } = context ;
8988
90- if ( ( entry = doc . findEntryByPathAndHash ( path , hash ) ) ) {
89+ let entry = doc . findEntryByPathAndHash ( path , hash ) ;
90+ if ( entry ) {
9191 context . doc = doc ;
9292 context . entry = entry ;
9393 this . triggerRoute ( "entry" ) ;
9494 return ;
9595 } else if ( path . slice ( - 6 ) === "/index" ) {
9696 path = path . substr ( 0 , path . length - 6 ) ;
97- if ( ( entry = doc . findEntryByPathAndHash ( path , hash ) ) ) {
97+ entry = doc . findEntryByPathAndHash ( path , hash ) ;
98+ if ( entry ) {
9899 return entry . fullPath ( ) ;
99100 }
100101 } else {
101102 path = `${ path } /index` ;
102- if ( ( entry = doc . findEntryByPathAndHash ( path , hash ) ) ) {
103+ entry = doc . findEntryByPathAndHash ( path , hash ) ;
104+ if ( entry ) {
103105 return entry . fullPath ( ) ;
104106 }
105107 }
@@ -169,10 +171,8 @@ app.Router = class Router extends Events {
169171
170172 setInitialPath ( ) {
171173 // Remove superfluous forward slashes at the beginning of the path
172- let path ;
173- if (
174- ( path = location . pathname . replace ( / ^ \/ { 2 , } / g, "/" ) ) !== location . pathname
175- ) {
174+ let path = location . pathname . replace ( / ^ \/ { 2 , } / g, "/" ) ;
175+ if ( path !== location . pathname ) {
176176 page . replace ( path + location . search + location . hash , null , true ) ;
177177 }
178178
@@ -192,8 +192,8 @@ app.Router = class Router extends Events {
192192 }
193193
194194 getInitialPathFromCookie ( ) {
195- let path ;
196- if ( ( path = Cookies . get ( "initial_path" ) ) ) {
195+ const path = Cookies . get ( "initial_path" ) ;
196+ if ( path ) {
197197 Cookies . expire ( "initial_path" ) ;
198198 return path ;
199199 }
@@ -203,7 +203,7 @@ app.Router = class Router extends Events {
203203 page . replace (
204204 location . pathname + location . search + ( hash || "" ) ,
205205 null ,
206- true ,
206+ true
207207 ) ;
208208 }
209209} ;
0 commit comments