expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenCalledWith(START, normalizedLoc, {
direction: 'back',
- distance: -1,
+ delta: -1,
type: 'pop',
})
history.go(1)
expect(spy).toHaveBeenCalledTimes(2)
expect(spy).toHaveBeenLastCalledWith(normalizedLoc, START, {
direction: 'forward',
- distance: 1,
+ delta: 1,
type: 'pop',
})
})
import { isBrowser } from '../utils'
+import { removeTrailingSlash } from '../location'
interface HistoryLocation {
fullPath: string
// remove the trailing slash so all other method can just do `base + fullPath`
// to build an href
- return base.replace(/\/$/, '')
+ return removeTrailingSlash(base)
}
hash?: string
}
+const TRAILING_SLASH_RE = /\/$/
+export const removeTrailingSlash = (path: string) =>
+ path.replace(TRAILING_SLASH_RE, '')
+
/**
* Transforms an URI into a normalized history location
*