From 1f28d501cc2e645ae98025b1386d1cd14540ceae Mon Sep 17 00:00:00 2001 From: wyattis Date: Tue, 25 May 2021 17:04:30 -0400 Subject: [PATCH] More resilient document version parsing from path --- packages/vuepress/vuepress-plugin-versioning/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vuepress/vuepress-plugin-versioning/index.js b/packages/vuepress/vuepress-plugin-versioning/index.js index 86ea5237..fda58723 100644 --- a/packages/vuepress/vuepress-plugin-versioning/index.js +++ b/packages/vuepress/vuepress-plugin-versioning/index.js @@ -148,7 +148,7 @@ module.exports = (options, context) => { } if (page._filePath.startsWith(versionedSourceDir)) { - const version = page._filePath.substring(versionedSourceDir.length + 1, page._filePath.indexOf('/', versionedSourceDir.length + 1)) + const version = page._filePath.replace(versionedSourceDir, '').split(path.sep).filter(p => !!p)[0] page.version = version page.originalRegularPath = page.regularPath const pathWithoutLeadingVersion = page.path.replace(new RegExp(`^/${version}`), '')