diff --git a/CHANGES.md b/CHANGES.md index bdd7fce07..9039fd525 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,16 @@ ## [HEAD] +#### Bug fixes - Disable browser history on Chrome iOS ([#146]) +- Do not convert same-path PUSH to REPLACE if the hash has changed ([#167]) + +#### Other - Add ES2015 module build ([#152]) [HEAD]: https://github.com/rackt/history/compare/latest...HEAD [#146]: https://github.com/rackt/history/pull/146 [#152]: https://github.com/rackt/history/pull/152 +[#167]: https://github.com/rackt/history/pull/167 ## [v1.13.1] > Nov 13, 2015 diff --git a/modules/__tests__/describeHashSupport.js b/modules/__tests__/describeHashSupport.js index 36b6e6364..542faf38f 100644 --- a/modules/__tests__/describeHashSupport.js +++ b/modules/__tests__/describeHashSupport.js @@ -36,6 +36,29 @@ function describeHashSupport(createHistory) { unlisten = history.listen(execSteps(steps, done)) }) + + it('does not convert PUSH to REPLACE if path does not change', function (done) { + const steps = [ + function (location) { + expect(location.pathname).toEqual('/') + expect(location.search).toEqual('') + expect(location.hash).toEqual('') + expect(location.state).toEqual(null) + expect(location.action).toEqual(POP) + + history.pushState(null, '/#the-hash') + }, + function (location) { + expect(location.pathname).toEqual('/') + expect(location.search).toEqual('') + expect(location.hash).toEqual('#the-hash') + expect(location.state).toEqual(null) + expect(location.action).toEqual(PUSH) + } + ] + + unlisten = history.listen(execSteps(steps, done)) + }) }) } diff --git a/modules/createHistory.js b/modules/createHistory.js index 081440cc3..c510da2cc 100644 --- a/modules/createHistory.js +++ b/modules/createHistory.js @@ -117,11 +117,10 @@ function createHistory(options={}) { if (ok) { // treat PUSH to current path like REPLACE to be consistent with browsers if (nextLocation.action === PUSH) { - let { pathname, search } = getCurrentLocation() - let currentPath = pathname + search - let path = nextLocation.pathname + nextLocation.search + const prevPath = createPath(location) + const nextPath = createPath(nextLocation) - if (currentPath === path) + if (nextPath === prevPath) nextLocation.action = REPLACE }