site-config-stack 0.8.13 → 0.8.14

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 CHANGED
@@ -73,11 +73,12 @@ function resolveSitePath(pathOrUrl, options) {
73
73
  const parsed = ufo.parseURL(pathOrUrl);
74
74
  path = parsed.pathname;
75
75
  }
76
- if (!options.withBase && path.startsWith(`/${options.base}`)) {
77
- path = path.slice(options.base.length + 1);
76
+ const base = ufo.withLeadingSlash(options.base);
77
+ if (base !== "/" && path.startsWith(base)) {
78
+ path = path.slice(base.length);
78
79
  }
79
80
  const origin = options.absolute ? options.siteUrl : "";
80
- const baseWithOrigin = options.withBase ? ufo.withBase(options.base, origin || "/") : origin;
81
+ const baseWithOrigin = options.withBase ? ufo.withBase(base, origin || "/") : origin;
81
82
  const resolvedUrl = ufo.withBase(path, baseWithOrigin);
82
83
  return path === "/" ? ufo.withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
83
84
  }
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 || {};
@@ -71,11 +71,12 @@ function resolveSitePath(pathOrUrl, options) {
71
71
  const parsed = parseURL(pathOrUrl);
72
72
  path = parsed.pathname;
73
73
  }
74
- if (!options.withBase && path.startsWith(`/${options.base}`)) {
75
- path = path.slice(options.base.length + 1);
74
+ const base = withLeadingSlash(options.base);
75
+ if (base !== "/" && path.startsWith(base)) {
76
+ path = path.slice(base.length);
76
77
  }
77
78
  const origin = options.absolute ? options.siteUrl : "";
78
- const baseWithOrigin = options.withBase ? withBase(options.base, origin || "/") : origin;
79
+ const baseWithOrigin = options.withBase ? withBase(base, origin || "/") : origin;
79
80
  const resolvedUrl = withBase(path, baseWithOrigin);
80
81
  return path === "/" ? withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
81
82
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "site-config-stack",
3
3
  "type": "module",
4
- "version": "0.8.13",
4
+ "version": "0.8.14",
5
5
  "description": "Shared site configuration utilities.",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",