Skip to content

Commit 1e9171f

Browse files
committed
support append: true in router navigation methods (close #911)
1 parent ed30899 commit 1e9171f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: flow/declarations.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ declare type Location = {
5858
hash?: string;
5959
query?: Dictionary<string>;
6060
params?: Dictionary<string>;
61+
append?: boolean;
6162
}
6263

6364
declare type RawLocation = string | Location

Diff for: src/util/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function normalizeLocation (
3636
const parsedPath = parsePath(next.path || '')
3737
const basePath = (current && current.path) || '/'
3838
const path = parsedPath.path
39-
? resolvePath(parsedPath.path, basePath, append)
39+
? resolvePath(parsedPath.path, basePath, append || next.append)
4040
: (current && current.path) || '/'
4141
const query = resolveQuery(parsedPath.query, next.query)
4242
let hash = next.hash || parsedPath.hash

Diff for: test/unit/specs/location.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ describe('Location utils', () => {
8888
expect(loc.path).toBe('/fr/foo')
8989
})
9090

91+
it('relative append', () => {
92+
const loc = normalizeLocation({ path: 'a' }, { path: '/b' }, true)
93+
expect(loc.path).toBe('/b/a')
94+
const loc2 = normalizeLocation({ path: 'a', append: true }, { path: '/b' })
95+
expect(loc2.path).toBe('/b/a')
96+
})
97+
9198
it('object', () => {
9299
const loc = normalizeLocation({
93100
path: '/abc?foo=bar#hello',

0 commit comments

Comments
 (0)