@vuepress/shared 2.0.0-rc.4 → 2.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +14 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -79,8 +79,20 @@ var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Ob
79
79
 
80
80
  // src/utils/normalizeRoutePath.ts
81
81
  var normalizeRoutePath = (path) => {
82
- const convertedMdPath = path.endsWith("README.md") ? path.substring(0, path.length - 9) : path.endsWith(".md") ? path.substring(0, path.length - 3) + ".html" : path;
83
- return convertedMdPath.endsWith("/index.html") ? convertedMdPath.substring(0, convertedMdPath.length - 10) : convertedMdPath.endsWith(".html") || convertedMdPath.endsWith("/") ? convertedMdPath : convertedMdPath + ".html";
82
+ const [pathname, ...rest] = path.split(/(\?|#)/);
83
+ if (!pathname || pathname.endsWith("/"))
84
+ return path;
85
+ const queryAndHash = rest.length > 0 ? rest.join("") : "";
86
+ let routePath = pathname.replace(/(^|\/)README.md$/i, "$1index.html");
87
+ if (routePath.endsWith(".md")) {
88
+ routePath = routePath.substring(0, routePath.length - 3) + ".html";
89
+ } else if (!routePath.endsWith(".html")) {
90
+ routePath = routePath + ".html";
91
+ }
92
+ if (routePath.endsWith("/index.html")) {
93
+ return routePath.substring(0, routePath.length - 10) + queryAndHash;
94
+ }
95
+ return routePath + queryAndHash;
84
96
  };
85
97
 
86
98
  // src/utils/omit.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/shared",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.6",
4
4
  "description": "Utils that shared between VuePress node and client",
5
5
  "keywords": [
6
6
  "vuepress",