const { Page, Action } = require('~')

const { action, dispatches } = require('evex')

// These pages don't work without current document set.
const MAIN_PAGES = [Page.BS, Page.JOURNAL, Page.SETTINGS, Page.EDIT_CHART_OF_ACCOUNTS]

/*
// These pages work without current document set.
const LANDING_PAGES = [
  Page.NEW,
  Page.APP_SETTINGS
]
*/

class LocationModule {
  isMainPage (pathname) {
    return MAIN_PAGES.indexOf(pathname) >= 0
  }

  /**
   * @param {domain.User} user The user
   */
  @action(Action.CHECK_LOCATION)
  checkLocation ({ user, location }) {
    const { pathname } = location

    if (user.currentDocument) {
      // If current document exists, then all pages are accesible
      return this.locationOk()
    }

    if (!this.isMainPage(pathname)) {
      // If it's not main page, then page is accessible
      return this.locationOk()
    }

    this.locationNg()
  }

  @dispatches(Action.LOCATION_OK)
  locationOk () {}

  @dispatches(Action.LOCATION_NG)
  locationNg () {}
}

module.exports = LocationModule

@@ -160,16 +160,19 @@
  = %5B
+%0A  
 Page.BS,
  Pag
@@ -167,16 +167,18 @@
 Page.BS,
+%0A 
  Page.JO
@@ -183,16 +183,18 @@
 JOURNAL,
+%0A 
  Page.SE
@@ -200,16 +200,18 @@
 ETTINGS,
+%0A 
  Page.ED
@@ -230,16 +230,17 @@
 ACCOUNTS
+%0A
 %5D%0A%0A/*%0A//
@@ -394,24 +394,103 @@
 pathname) %7B%0A
+    if (/%5C/$/.test(pathname)) %7B%0A      pathname = pathname + 'index.html'%0A    %7D%0A
     return M

fix path check