File tree 1 file changed +5
-3
lines changed
packages/@vuepress/shared-utils/src
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ interface PermalinkOption {
9
9
localePath : string ;
10
10
}
11
11
12
+ function removeLeadingSlash ( path : string ) {
13
+ return path . replace ( / ^ \/ / , '' )
14
+ }
12
15
// e.g.
13
16
// filename: docs/_posts/evan you.md
14
17
// content: # yyx 990803
@@ -39,8 +42,7 @@ export = function getPermalink ({
39
42
const month = iMonth < 10 ? `0${ iMonth } ` : iMonth
40
43
const day = iDay < 10 ? `0${ iDay } ` : iDay
41
44
42
- // Remove leading slash
43
- pattern = pattern . replace ( / ^ \/ / , '' )
45
+ pattern = removeLeadingSlash ( pattern )
44
46
45
47
const link =
46
48
localePath +
@@ -53,7 +55,7 @@ export = function getPermalink ({
53
55
. replace ( / : m i n u t e s / , String ( minutes ) )
54
56
. replace ( / : s e c o n d s / , String ( seconds ) )
55
57
. replace ( / : s l u g / , slug )
56
- . replace ( / : r e g u l a r / , regularPath )
58
+ . replace ( / : r e g u l a r / , removeLeadingSlash ( regularPath ) )
57
59
58
60
return ensureLeadingSlash ( ensureEndingSlash ( link ) )
59
61
}
You can’t perform that action at this time.
0 commit comments