Skip to content

Commit

Permalink
only handle hashes that start with a '/'
Browse files Browse the repository at this point in the history
- createHashHistory now only handles hashes that start with a '/' on
  history-change
- on startup, a '/' is still prepended if missing

Change-Id: Ibed14c8acde9c1ea022508c29be8b04df175d466
  • Loading branch information
cwrs committed Nov 23, 2015
1 parent 9a5a378 commit 4b18a43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [HEAD]

- `createHashHistory` now only handles hashes that start with a '/' as only those urls may be created by the history

- Disable browser history on Chrome iOS ([#146])
- Add ES2015 module build ([#152])

Expand Down
4 changes: 2 additions & 2 deletions modules/__tests__/HashHistory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import describeGo from './describeGo'

describe('hash history', function () {
beforeEach(function () {
if (window.location.hash !== '')
window.location.hash = ''
if (window.location.hash !== '/')
window.location.hash = '/'
})

describeInitialLocation(createHashHistory)
Expand Down
4 changes: 2 additions & 2 deletions modules/createHashHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ function createHashHistory(options={}) {

function startHashChangeListener({ transitionTo }) {
function hashChangeListener() {
if (!ensureSlash())
return // Always make sure hashes are preceeded with a /.
if (!isAbsolutePath(getHashPath()))
return // Only handle hashes which are could be created by the history.

transitionTo(
getCurrentLocation()
Expand Down

0 comments on commit 4b18a43

Please sign in to comment.