site-config-stack 0.8.13 → 0.8.17
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 +6 -3
- package/dist/index.mjs +7 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,8 @@ const envSiteConfig = {
|
|
|
28
28
|
function createSiteConfigStack() {
|
|
29
29
|
const stack = [];
|
|
30
30
|
function push(input) {
|
|
31
|
+
if (!input || typeof input !== "object" || Object.keys(input).length === 0)
|
|
32
|
+
return;
|
|
31
33
|
if (!input._context) {
|
|
32
34
|
let lastFunctionName = new Error("tmp").stack?.split("\n")[2].split(" ")[5];
|
|
33
35
|
if (lastFunctionName?.includes("/"))
|
|
@@ -73,11 +75,12 @@ function resolveSitePath(pathOrUrl, options) {
|
|
|
73
75
|
const parsed = ufo.parseURL(pathOrUrl);
|
|
74
76
|
path = parsed.pathname;
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const base = ufo.withLeadingSlash(options.base);
|
|
79
|
+
if (base !== "/" && path.startsWith(base)) {
|
|
80
|
+
path = path.slice(base.length);
|
|
78
81
|
}
|
|
79
82
|
const origin = options.absolute ? options.siteUrl : "";
|
|
80
|
-
const baseWithOrigin = options.withBase ? ufo.withBase(
|
|
83
|
+
const baseWithOrigin = options.withBase ? ufo.withBase(base, origin || "/") : origin;
|
|
81
84
|
const resolvedUrl = ufo.withBase(path, baseWithOrigin);
|
|
82
85
|
return path === "/" ? ufo.withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
|
|
83
86
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasProtocol, withHttps, parseURL, withBase, withTrailingSlash, withoutTrailingSlash } from 'ufo';
|
|
1
|
+
import { hasProtocol, withHttps, parseURL, withLeadingSlash, withBase, withTrailingSlash, withoutTrailingSlash } from 'ufo';
|
|
2
2
|
|
|
3
3
|
const processShim = typeof process !== "undefined" ? process : {};
|
|
4
4
|
const envShim = processShim.env || {};
|
|
@@ -26,6 +26,8 @@ const envSiteConfig = {
|
|
|
26
26
|
function createSiteConfigStack() {
|
|
27
27
|
const stack = [];
|
|
28
28
|
function push(input) {
|
|
29
|
+
if (!input || typeof input !== "object" || Object.keys(input).length === 0)
|
|
30
|
+
return;
|
|
29
31
|
if (!input._context) {
|
|
30
32
|
let lastFunctionName = new Error("tmp").stack?.split("\n")[2].split(" ")[5];
|
|
31
33
|
if (lastFunctionName?.includes("/"))
|
|
@@ -71,11 +73,12 @@ function resolveSitePath(pathOrUrl, options) {
|
|
|
71
73
|
const parsed = parseURL(pathOrUrl);
|
|
72
74
|
path = parsed.pathname;
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const base = withLeadingSlash(options.base);
|
|
77
|
+
if (base !== "/" && path.startsWith(base)) {
|
|
78
|
+
path = path.slice(base.length);
|
|
76
79
|
}
|
|
77
80
|
const origin = options.absolute ? options.siteUrl : "";
|
|
78
|
-
const baseWithOrigin = options.withBase ? withBase(
|
|
81
|
+
const baseWithOrigin = options.withBase ? withBase(base, origin || "/") : origin;
|
|
79
82
|
const resolvedUrl = withBase(path, baseWithOrigin);
|
|
80
83
|
return path === "/" ? withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
|
|
81
84
|
}
|