Skip to content

Commit 6782849

Browse files
committed
Refactored src/app/book/services/router.service.ts
1 parent e0c25a6 commit 6782849

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/app/book/services/router.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class RouterService {
4949
let path = this._url.pathname;
5050
const fragment = this._url.hash ? decodeURI(this._url.hash) : '';
5151

52-
const re = new RegExp(/\.md/)
52+
let re = new RegExp(/\.md/)
5353
const notHomePage = re.test(path);
5454

5555
let url: string;
@@ -64,7 +64,10 @@ export class RouterService {
6464
root = path.endsWith('/') ? path : path+'/';
6565
}
6666

67-
if(url.endsWith('/')) url = url.slice(0, -1);
67+
// 去掉最后的 '/'
68+
re = new RegExp(/.*\/$/);
69+
if(re.test(url)) url = url.slice(0, -1);
70+
6871
path = url+fragment;
6972
this.go(path, root);
7073
}

0 commit comments

Comments
 (0)