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
Refactor: utility method moved to utility file
rgladwell committed Feb 6, 2021
commit 831527f389d0872bb5e37536f705d4254781d247
7 changes: 1 addition & 6 deletions src/core/router/history/hash.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { noop } from '../../util/core';
import { on } from '../../util/dom';
import { parseQuery, cleanPath, replaceSlug } from '../util';
import { parseQuery, cleanPath, replaceSlug, endsWith } from '../util';
import { History } from './base';

function replaceHash(path) {
const i = location.href.indexOf('#');
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);
4 changes: 4 additions & 0 deletions src/core/router/util.js
Original file line number Diff line number Diff line change
@@ -113,3 +113,7 @@ export function getPath(...args) {
export const replaceSlug = cached(path => {
return path.replace('#', '?id=');
});

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