Skip to content

Commit ac5ed77

Browse files
committed
Fix: endsWith() not supported for IE11
1 parent 5e4c790 commit ac5ed77

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/router/history/hash.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ function replaceHash(path) {
88
location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path);
99
}
1010

11+
function endsWith(str, suffix) {
12+
return str.indexOf(suffix, str.length - suffix.length) !== -1;
13+
}
14+
1115
export class HashHistory extends History {
1216
constructor(config) {
1317
super(config);
@@ -23,7 +27,7 @@ export class HashHistory extends History {
2327
// prevents the `/index.html` part of the URI from being
2428
// remove during routing.
2529
// See here: https://github.com/docsifyjs/docsify/pull/1372
26-
const basePath = path.endsWith('.html')
30+
const basePath = endsWith(path, '.html')
2731
? path + '#/' + base
2832
: path + '/' + base;
2933
return /^(\/|https?:)/g.test(base) ? base : cleanPath(basePath);

0 commit comments

Comments
 (0)