diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-03-04 17:49:37 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-03-04 17:49:37 +0100 |
commit | bc5e0d40113ff12fac9d460e264ec620d3b04735 (patch) | |
tree | fe1392cfb853dd9c5077477c582c721b9b3f21c1 /js | |
parent | a76caf717fd2c60f30bc62baa2522a16e4467268 (diff) | |
download | site-bc5e0d40113ff12fac9d460e264ec620d3b04735.tar.gz |
Select home when hash is not given.
Diffstat (limited to 'js')
-rw-r--r-- | js/main.js | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -29,11 +29,15 @@ addEventListener('hashchange', function(ev) { var m = /#\/(.+)/.exec(ev.newURL); - if (!m) - return; - selectPage(m[1]); + if (m) { + selectPage(m[1]); + } else if (!/#/.test(ev.newURL)) { + location.hash = '#/home'; + } }); // Tries to load the current page, falling back to "home" for unknown URLs. - selectPage(location.hash.replace(/^#\//, '')) || selectPage('home'); + if (!selectPage(location.hash.replace(/^#\//, ''))) { + location.hash = '#/home'; + } })(); |