import ScrollBehavior from 'scroll-behavior'
import SessionStorage from './SessionStorage'

export default ({ shouldUpdateScroll, manual }) => history => {
  const stateStorage = new SessionStorage()

  const behavior = new ScrollBehavior({
    addTransitionHook: history.listen,
    stateStorage,
    getCurrentLocation: () => ({
      ...history.location,
      action: history.action
    }),
    shouldUpdateScroll
  })

  behavior.setPrevKey = () => {
    const key = history.location.key || history.location.hash || 'loadPage'
    stateStorage.setPrevKey(key)
  }

  behavior.manual = manual

  return behavior
}

@@ -131,16 +131,21 @@
 manual %7D
+ = %7B%7D
 ) =%3E his

Fix error when using default