Skip to content

Commit 8018705

Browse files
fix(vuejs#2725): remove duplicated decodeURIComponent
1 parent 6ab3769 commit 8018705

File tree

5 files changed

+4
-16
lines changed

5 files changed

+4
-16
lines changed

examples/basic/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const vueInstance = new Vue({
7575
</li>
7676
</router-link>
7777
<li><router-link to="/foo" replace>/foo (replace)</router-link></li>
78-
<li><router-link to="/query/A%">/query/A%</router-link></li>
78+
<li><router-link to="/query/A%25">/query/A%</router-link></li>
7979
</ul>
8080
<button id="navigate-btn" @click="navigateAndIncrement">On Success</button>
8181
<pre id="counter">{{ n }}</pre>

examples/hash-mode/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const vueInstance = new Vue({
6868
<li><router-link to="/é/ñ">/é/ñ</router-link></li>
6969
<li><router-link to="/é/ñ?t=%25ñ">/é/ñ?t=%ñ</router-link></li>
7070
<li><router-link to="/é/ñ#é">/é/ñ#é</router-link></li>
71-
<li><router-link to="/query/A%">/query/A%</router-link></li>
71+
<li><router-link to="/query/A%25">/query/A%</router-link></li>
7272
</ul>
7373
<pre id="query-t">{{ $route.query.t }}</pre>
7474
<pre id="hash">{{ $route.hash }}</pre>

src/create-matcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function matchRoute (
175175
path: string,
176176
params: Object
177177
): boolean {
178-
const m = path.match(regex)
178+
const m = decodeURI(path).match(regex)
179179

180180
if (!m) {
181181
return false

src/history/hash.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,6 @@ export function getHash (): string {
124124
if (index < 0) return ''
125125

126126
href = href.slice(index + 1)
127-
// decode the hash but not the search or hash
128-
// as search(query) is already decoded
129-
// https://github.com/vuejs/vue-router/issues/2708
130-
const searchIndex = href.indexOf('?')
131-
if (searchIndex < 0) {
132-
const hashIndex = href.indexOf('#')
133-
if (hashIndex > -1) {
134-
href = decodeURI(href.slice(0, hashIndex)) + href.slice(hashIndex)
135-
} else href = decodeURI(href)
136-
} else {
137-
href = decodeURI(href.slice(0, searchIndex)) + href.slice(searchIndex)
138-
}
139127

140128
return href
141129
}

src/history/html5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class HTML5History extends History {
8686
}
8787

8888
export function getLocation (base: string): string {
89-
let path = decodeURI(window.location.pathname)
89+
let path = window.location.pathname
9090
if (base && path.toLowerCase().indexOf(base.toLowerCase()) === 0) {
9191
path = path.slice(base.length)
9292
}

0 commit comments

Comments
 (0)