Skip to content

Commit 831527f

Browse files
committed
Refactor: utility method moved to utility file
1 parent ac5ed77 commit 831527f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/core/router/history/hash.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import { noop } from '../../util/core';
22
import { on } from '../../util/dom';
3-
import { parseQuery, cleanPath, replaceSlug } from '../util';
3+
import { parseQuery, cleanPath, replaceSlug, endsWith } from '../util';
44
import { History } from './base';
55

66
function replaceHash(path) {
77
const i = location.href.indexOf('#');
88
location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path);
99
}
10-
11-
function endsWith(str, suffix) {
12-
return str.indexOf(suffix, str.length - suffix.length) !== -1;
13-
}
14-
1510
export class HashHistory extends History {
1611
constructor(config) {
1712
super(config);

src/core/router/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ export function getPath(...args) {
113113
export const replaceSlug = cached(path => {
114114
return path.replace('#', '?id=');
115115
});
116+
117+
export function endsWith(str, suffix) {
118+
return str.indexOf(suffix, str.length - suffix.length) !== -1;
119+
}

0 commit comments

Comments
 (0)