Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cannot serve off /.../index.html #1372

Merged
Prev Previous commit
Next Next commit
Fix: endsWith() not supported for IE11
rgladwell committed Feb 6, 2021
commit ac5ed770ff25ee7ebb52bf893d1269b30580549b
6 changes: 5 additions & 1 deletion src/core/router/history/hash.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,10 @@ function replaceHash(path) {
location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path);
}

function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

export class HashHistory extends History {
constructor(config) {
super(config);
@@ -23,7 +27,7 @@ export class HashHistory extends History {
// prevents the `/index.html` part of the URI from being
// remove during routing.
// See here: https://github.com/docsifyjs/docsify/pull/1372
const basePath = path.endsWith('.html')
const basePath = endsWith(path, '.html')
? path + '#/' + base
: path + '/' + base;
return /^(\/|https?:)/g.test(base) ? base : cleanPath(basePath);