diff --git a/packages/history/__tests__/TestSequences/ReplaceNewLocation.js b/packages/history/__tests__/TestSequences/ReplaceNewLocation.js index 1d13fd365..1522858fc 100644 --- a/packages/history/__tests__/TestSequences/ReplaceNewLocation.js +++ b/packages/history/__tests__/TestSequences/ReplaceNewLocation.js @@ -20,6 +20,17 @@ export default (history, done) => { state: null, key: expect.any(String) }); + + history.replace('/'); + }, + ({ action, location }) => { + expect(action).toBe('REPLACE'); + expect(location).toMatchObject({ + pathname: '/', + search: '', + state: null, + key: expect.any(String) + }); } ]; diff --git a/packages/history/index.ts b/packages/history/index.ts index 11ae53326..a0a920ee3 100644 --- a/packages/history/index.ts +++ b/packages/history/index.ts @@ -1051,7 +1051,9 @@ export function createPath({ * @see https://github.com/ReactTraining/history/tree/master/docs/api-reference.md#parsepath */ export function parsePath(path: string) { - let partialPath: PartialPath = {}; + let partialPath: PartialPath = { + search: '' + }; if (path) { let hashIndex = path.indexOf('#');