diff --git a/examples/hash-mode/app.js b/examples/hash-mode/app.js index ebc1aba4e..f90da3255 100644 --- a/examples/hash-mode/app.js +++ b/examples/hash-mode/app.js @@ -10,6 +10,7 @@ Vue.use(VueRouter) const Home = { template: '
home
' } const Foo = { template: '
foo
' } const Bar = { template: '
bar
' } +const Unicode = { template: '
unicode
' } // 3. Create the router const router = new VueRouter({ @@ -18,7 +19,8 @@ const router = new VueRouter({ routes: [ { path: '/', component: Home }, // all paths are defined without the hash. { path: '/foo', component: Foo }, - { path: '/bar', component: Bar } + { path: '/bar', component: Bar }, + { path: '/é', component: Unicode } ] }) @@ -35,6 +37,7 @@ new Vue({
  • /foo
  • /bar
  • /bar +
  • diff --git a/src/history/hash.js b/src/history/hash.js index f4a2f3828..330f2383c 100644 --- a/src/history/hash.js +++ b/src/history/hash.js @@ -102,7 +102,7 @@ export function getHash (): string { // consistent across browsers - Firefox will pre-decode it! const href = window.location.href const index = href.indexOf('#') - return index === -1 ? '' : href.slice(index + 1) + return index === -1 ? '' : decodeURI(href.slice(index + 1)) } function getUrl (path) { diff --git a/test/e2e/specs/hash-mode.js b/test/e2e/specs/hash-mode.js index d6b74369f..33c1df0c5 100644 --- a/test/e2e/specs/hash-mode.js +++ b/test/e2e/specs/hash-mode.js @@ -3,11 +3,12 @@ module.exports = { browser .url('http://localhost:8080/hash-mode/') .waitForElementVisible('#app', 1000) - .assert.count('li', 4) - .assert.count('li a', 3) + .assert.count('li', 5) + .assert.count('li a', 4) .assert.attributeContains('li:nth-child(1) a', 'href', '/hash-mode/#/') .assert.attributeContains('li:nth-child(2) a', 'href', '/hash-mode/#/foo') .assert.attributeContains('li:nth-child(3) a', 'href', '/hash-mode/#/bar') + .assert.attributeContains('li:nth-child(5) a', 'href', '/hash-mode/#/%C3%A9') .assert.containsText('.view', 'home') .click('li:nth-child(2) a') @@ -30,6 +31,9 @@ module.exports = { .url('http://localhost:8080/hash-mode/#/foo') .waitForElementVisible('#app', 1000) .assert.containsText('.view', 'foo') + .url('http://localhost:8080/hash-mode/#/%C3%A9') + .waitForElementVisible('#app', 1000) + .assert.containsText('.view', 'unicode') .end() } }