await expect(router.push('/foo')).resolves.toBe(undefined)
expect('with path "/foo" is a function').toHaveBeenWarned()
})
+
+ it('should warn if multiple leading slashes with raw location', async () => {
+ const router = createRouter({
+ history: createMemoryHistory(),
+ routes: [{ path: '/foo', component }],
+ })
+
+ await expect(router.push('//not-valid')).resolves.toBe(undefined)
+ expect('cannot start with multiple slashes').toHaveBeenWarned()
+ })
+
+ it('should warn if multiple leading slashes with object location', async () => {
+ const router = createRouter({
+ history: createMemoryHistory(),
+ routes: [{ path: '/foo', component }],
+ })
+
+ await expect(router.push({ path: '//not-valid' })).resolves.toBe(undefined)
+ expect('cannot start with multiple slashes').toHaveBeenWarned()
+ })
})
currentLocation
)
+ if (__DEV__) {
+ let href = routerHistory.base + locationNormalized.fullPath
+ if (href.startsWith('//'))
+ warn(
+ `Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`
+ )
+ }
+
return {
// fullPath: locationNormalized.fullPath,
// query: locationNormalized.query,
path: matchedRoute.path,
})
+ if (__DEV__) {
+ let href = routerHistory.base + fullPath
+ if (href.startsWith('//'))
+ warn(
+ `Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`
+ )
+ }
+
return {
fullPath,
// keep the hash encoded so fullPath is effectively path + encodedQuery +