Skip to content

Commit ea23046

Browse files
committed
Merge branch 'query-omit'
2 parents 880f7fb + 3ffeefd commit ea23046

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

__tests__/NavLink.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test('isActive returns true', () => {
7676
isActive: (match, location) => {
7777
expect(match).toMatchSnapshot()
7878
expect(location).toMatchSnapshot()
79-
return true
79+
return match
8080
}
8181
})
8282

@@ -125,3 +125,12 @@ it('supports custom HTML tag name which is still a link', () => {
125125

126126
expect(tree).toMatchSnapshot()
127127
})
128+
129+
test('query params are ommitted', () => {
130+
const { tree } = createNavLink('/first', {
131+
to: '/first?foo=123',
132+
activeClassName: 'active'
133+
})
134+
135+
expect(tree).toMatchSnapshot()
136+
})

__tests__/__snapshots__/NavLink.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ exports[`isActive returns true 3`] = `
123123
/>
124124
`;
125125

126+
exports[`query params are ommitted 1`] = `
127+
<a
128+
aria-current="true"
129+
className="active"
130+
href="/first?foo=123"
131+
onClick={[Function]}
132+
style={Object {}}
133+
/>
134+
`;
135+
126136
exports[`reacts to state changes (onClick) 1`] = `
127137
<a
128138
aria-current={false}

src/NavLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const NavLink = (
6363
to = href || to
6464

6565
const location = selectLocationState(store.getState())
66-
const path = toUrl(to, location.routesMap)
66+
const path = toUrl(to, location.routesMap).split('?')[0]
6767
const match = matchPath(pathname, { path, exact, strict })
6868
const active = !!(isActive ? isActive(match, location) : match)
6969

0 commit comments

Comments
 (0)