site-config-stack 3.0.3 → 3.0.5

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
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const ufo = require('ufo');
4
3
  const vue = require('vue');
4
+ const ufo = require('ufo');
5
5
 
6
6
  function normalizeSiteConfig(config) {
7
7
  if (typeof config.indexable !== "undefined")
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { hasProtocol, withHttps, parseURL, getQuery } from 'ufo';
2
1
  import { toValue } from 'vue';
2
+ import { hasProtocol, withHttps, parseURL, getQuery } from 'ufo';
3
3
 
4
4
  function normalizeSiteConfig(config) {
5
5
  if (typeof config.indexable !== "undefined")
package/dist/urls.cjs CHANGED
@@ -12,26 +12,19 @@ function resolveSitePath(pathOrUrl, options) {
12
12
  if (base !== "/" && path.startsWith(base)) {
13
13
  path = path.slice(base.length);
14
14
  }
15
- let origin = ufo.withoutTrailingSlash(options.absolute ? options.siteUrl : "");
16
- if (base !== "/" && origin.endsWith(base)) {
17
- origin = origin.slice(0, origin.indexOf(base));
18
- }
15
+ const origin = options.absolute ? options.siteUrl : "";
19
16
  const baseWithOrigin = options.withBase ? ufo.withBase(base, origin || "/") : origin;
20
17
  const resolvedUrl = ufo.withBase(path, baseWithOrigin);
21
18
  return path === "/" && !options.withBase ? ufo.withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
22
19
  }
23
- function isPathFile(path) {
24
- const lastSegment = path.split("/").pop();
25
- return !!(lastSegment || path).match(/\.[0-9a-z]+$/i)?.[0];
26
- }
27
20
  function fixSlashes(trailingSlash, pathOrUrl) {
28
21
  const $url = ufo.parseURL(pathOrUrl);
29
- if (isPathFile($url.pathname))
22
+ const isFileUrl = $url.pathname.includes(".");
23
+ if (isFileUrl)
30
24
  return pathOrUrl;
31
25
  const fixedPath = trailingSlash ? ufo.withTrailingSlash($url.pathname) : ufo.withoutTrailingSlash($url.pathname);
32
26
  return `${$url.protocol ? `${$url.protocol}//` : ""}${$url.host || ""}${fixedPath}${$url.search || ""}${$url.hash || ""}`;
33
27
  }
34
28
 
35
29
  exports.fixSlashes = fixSlashes;
36
- exports.isPathFile = isPathFile;
37
30
  exports.resolveSitePath = resolveSitePath;
package/dist/urls.d.cts CHANGED
@@ -5,7 +5,6 @@ declare function resolveSitePath(pathOrUrl: string, options: {
5
5
  absolute?: boolean;
6
6
  withBase?: boolean;
7
7
  }): string;
8
- declare function isPathFile(path: string): boolean;
9
8
  declare function fixSlashes(trailingSlash: boolean | undefined, pathOrUrl: string): string;
10
9
 
11
- export { fixSlashes, isPathFile, resolveSitePath };
10
+ export { fixSlashes, resolveSitePath };
package/dist/urls.d.mts CHANGED
@@ -5,7 +5,6 @@ declare function resolveSitePath(pathOrUrl: string, options: {
5
5
  absolute?: boolean;
6
6
  withBase?: boolean;
7
7
  }): string;
8
- declare function isPathFile(path: string): boolean;
9
8
  declare function fixSlashes(trailingSlash: boolean | undefined, pathOrUrl: string): string;
10
9
 
11
- export { fixSlashes, isPathFile, resolveSitePath };
10
+ export { fixSlashes, resolveSitePath };
package/dist/urls.d.ts CHANGED
@@ -5,7 +5,6 @@ declare function resolveSitePath(pathOrUrl: string, options: {
5
5
  absolute?: boolean;
6
6
  withBase?: boolean;
7
7
  }): string;
8
- declare function isPathFile(path: string): boolean;
9
8
  declare function fixSlashes(trailingSlash: boolean | undefined, pathOrUrl: string): string;
10
9
 
11
- export { fixSlashes, isPathFile, resolveSitePath };
10
+ export { fixSlashes, resolveSitePath };
package/dist/urls.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { hasProtocol, parseURL, withLeadingSlash, withoutTrailingSlash, withBase, withTrailingSlash } from 'ufo';
1
+ import { hasProtocol, parseURL, withLeadingSlash, withBase, withTrailingSlash, withoutTrailingSlash } from 'ufo';
2
2
 
3
3
  function resolveSitePath(pathOrUrl, options) {
4
4
  let path = pathOrUrl;
@@ -10,24 +10,18 @@ function resolveSitePath(pathOrUrl, options) {
10
10
  if (base !== "/" && path.startsWith(base)) {
11
11
  path = path.slice(base.length);
12
12
  }
13
- let origin = withoutTrailingSlash(options.absolute ? options.siteUrl : "");
14
- if (base !== "/" && origin.endsWith(base)) {
15
- origin = origin.slice(0, origin.indexOf(base));
16
- }
13
+ const origin = options.absolute ? options.siteUrl : "";
17
14
  const baseWithOrigin = options.withBase ? withBase(base, origin || "/") : origin;
18
15
  const resolvedUrl = withBase(path, baseWithOrigin);
19
16
  return path === "/" && !options.withBase ? withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
20
17
  }
21
- function isPathFile(path) {
22
- const lastSegment = path.split("/").pop();
23
- return !!(lastSegment || path).match(/\.[0-9a-z]+$/i)?.[0];
24
- }
25
18
  function fixSlashes(trailingSlash, pathOrUrl) {
26
19
  const $url = parseURL(pathOrUrl);
27
- if (isPathFile($url.pathname))
20
+ const isFileUrl = $url.pathname.includes(".");
21
+ if (isFileUrl)
28
22
  return pathOrUrl;
29
23
  const fixedPath = trailingSlash ? withTrailingSlash($url.pathname) : withoutTrailingSlash($url.pathname);
30
24
  return `${$url.protocol ? `${$url.protocol}//` : ""}${$url.host || ""}${fixedPath}${$url.search || ""}${$url.hash || ""}`;
31
25
  }
32
26
 
33
- export { fixSlashes, isPathFile, resolveSitePath };
27
+ export { fixSlashes, resolveSitePath };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "site-config-stack",
3
3
  "type": "module",
4
- "version": "3.0.3",
4
+ "version": "3.0.5",
5
5
  "description": "Shared site configuration utilities.",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",