File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
packages/@vuepress/shared-utils/src Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ interface PermalinkOption {
99 localePath : string ;
1010}
1111
12+ function removeLeadingSlash ( path : string ) {
13+ return path . replace ( / ^ \/ / , '' )
14+ }
1215// e.g.
1316// filename: docs/_posts/evan you.md
1417// content: # yyx 990803
@@ -39,8 +42,7 @@ export = function getPermalink ({
3942 const month = iMonth < 10 ? `0${ iMonth } ` : iMonth
4043 const day = iDay < 10 ? `0${ iDay } ` : iDay
4144
42- // Remove leading slash
43- pattern = pattern . replace ( / ^ \/ / , '' )
45+ pattern = removeLeadingSlash ( pattern )
4446
4547 const link =
4648 localePath +
@@ -53,7 +55,7 @@ export = function getPermalink ({
5355 . replace ( / : m i n u t e s / , String ( minutes ) )
5456 . replace ( / : s e c o n d s / , String ( seconds ) )
5557 . 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 ) )
5759
5860 return ensureLeadingSlash ( ensureEndingSlash ( link ) )
5961}
You can’t perform that action at this time.
0 commit comments