@vite-pwa/vitepress 0.2.2 → 0.2.3
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.
- package/dist/index.cjs +5 -4
- package/dist/index.mjs +5 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -106,10 +106,8 @@ function withUserConfig(config) {
|
|
|
106
106
|
if (typeof allowlist !== "undefined") {
|
|
107
107
|
const base = siteConfig.site.base ?? "/";
|
|
108
108
|
for (const page of siteConfig.pages) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
else
|
|
112
|
-
allowlist.push(new RegExp(`^${base}${page.replace(/\.md$/, "(.html)?")}$`));
|
|
109
|
+
const regex = page === "index.md" ? escapeStringRegexp(base) : escapeStringRegexp(`${base}${page.replace(/\.md$/, "")}`);
|
|
110
|
+
allowlist.push(new RegExp(`^${regex}(\\.html)?$`));
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
await api.generateSW();
|
|
@@ -117,6 +115,9 @@ function withUserConfig(config) {
|
|
|
117
115
|
};
|
|
118
116
|
return vitePressConfig;
|
|
119
117
|
}
|
|
118
|
+
function escapeStringRegexp(value) {
|
|
119
|
+
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
120
|
+
}
|
|
120
121
|
|
|
121
122
|
async function withPwa(config) {
|
|
122
123
|
if (typeof config === "function") {
|
package/dist/index.mjs
CHANGED
|
@@ -104,10 +104,8 @@ function withUserConfig(config) {
|
|
|
104
104
|
if (typeof allowlist !== "undefined") {
|
|
105
105
|
const base = siteConfig.site.base ?? "/";
|
|
106
106
|
for (const page of siteConfig.pages) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
else
|
|
110
|
-
allowlist.push(new RegExp(`^${base}${page.replace(/\.md$/, "(.html)?")}$`));
|
|
107
|
+
const regex = page === "index.md" ? escapeStringRegexp(base) : escapeStringRegexp(`${base}${page.replace(/\.md$/, "")}`);
|
|
108
|
+
allowlist.push(new RegExp(`^${regex}(\\.html)?$`));
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
await api.generateSW();
|
|
@@ -115,6 +113,9 @@ function withUserConfig(config) {
|
|
|
115
113
|
};
|
|
116
114
|
return vitePressConfig;
|
|
117
115
|
}
|
|
116
|
+
function escapeStringRegexp(value) {
|
|
117
|
+
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
118
|
+
}
|
|
118
119
|
|
|
119
120
|
async function withPwa(config) {
|
|
120
121
|
if (typeof config === "function") {
|