dom.reconfigure({ url: 'https://example.com' })
})
- it('should use a correct', () => {
+ it('should use a correct base', () => {
createWebHashHistory()
expect(createWebHistory).toHaveBeenCalledWith('/#')
})
it('should be able to provide a base with no trailing slash', () => {
createWebHashHistory('/folder')
- expect(createWebHistory).toHaveBeenCalledWith('/folder/#')
- })
-
- it('should read the base tag', () => {
- const baseEl = document.createElement('base')
- baseEl.href = '/foo/'
- document.head.appendChild(baseEl)
- createWebHashHistory()
- expect(createWebHistory).toHaveBeenCalledWith('/foo/#')
+ expect(createWebHistory).toHaveBeenCalledWith('/folder#')
})
it('should use the base option over the base tag', () => {
}
const router = createRouter({
- history: createWebHashHistory('/' + __dirname),
+ // keep a trailing slash in this specific case because we are using a hash
+ // history
+ history: createWebHashHistory('/' + __dirname + '/'),
routes: [
{ path: '/', component: Home },
{ path: '/foo', component: Foo },
-import { RouterHistory, normalizeBase } from './common'
+import { RouterHistory } from './common'
import { createWebHistory } from './html5'
-export function createWebHashHistory(base?: string): RouterHistory {
+export function createWebHashHistory(base: string = '/'): RouterHistory {
// Make sure this implementation is fine in terms of encoding, specially for IE11
- return createWebHistory(location.host ? normalizeBase(base) + '/#' : '#')
+ return createWebHistory(location.host ? base + '#' : '#')
}