site-config-stack 3.0.5 → 3.0.7

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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Harlan Wilton
3
+ Copyright (c) 2023-Present - Harlan Wilton
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const vue = require('vue');
4
3
  const ufo = require('ufo');
4
+ const vue = require('vue');
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 { toValue } from 'vue';
2
1
  import { hasProtocol, withHttps, parseURL, getQuery } from 'ufo';
2
+ import { toValue } from 'vue';
3
3
 
4
4
  function normalizeSiteConfig(config) {
5
5
  if (typeof config.indexable !== "undefined")
package/dist/urls.cjs CHANGED
@@ -12,19 +12,26 @@ function resolveSitePath(pathOrUrl, options) {
12
12
  if (base !== "/" && path.startsWith(base)) {
13
13
  path = path.slice(base.length);
14
14
  }
15
- const origin = options.absolute ? options.siteUrl : "";
15
+ let origin = ufo.withoutTrailingSlash(options.absolute ? options.siteUrl : "");
16
+ if (base !== "/" && origin.endsWith(base)) {
17
+ origin = origin.slice(0, origin.indexOf(base));
18
+ }
16
19
  const baseWithOrigin = options.withBase ? ufo.withBase(base, origin || "/") : origin;
17
20
  const resolvedUrl = ufo.withBase(path, baseWithOrigin);
18
21
  return path === "/" && !options.withBase ? ufo.withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
19
22
  }
23
+ function isPathFile(path) {
24
+ const lastSegment = path.split("/").pop();
25
+ return !!(lastSegment || path).match(/\.[0-9a-z]+$/i)?.[0];
26
+ }
20
27
  function fixSlashes(trailingSlash, pathOrUrl) {
21
28
  const $url = ufo.parseURL(pathOrUrl);
22
- const isFileUrl = $url.pathname.includes(".");
23
- if (isFileUrl)
29
+ if (isPathFile($url.pathname))
24
30
  return pathOrUrl;
25
31
  const fixedPath = trailingSlash ? ufo.withTrailingSlash($url.pathname) : ufo.withoutTrailingSlash($url.pathname);
26
32
  return `${$url.protocol ? `${$url.protocol}//` : ""}${$url.host || ""}${fixedPath}${$url.search || ""}${$url.hash || ""}`;
27
33
  }
28
34
 
29
35
  exports.fixSlashes = fixSlashes;
36
+ exports.isPathFile = isPathFile;
30
37
  exports.resolveSitePath = resolveSitePath;
package/dist/urls.d.cts CHANGED
@@ -5,6 +5,7 @@ declare function resolveSitePath(pathOrUrl: string, options: {
5
5
  absolute?: boolean;
6
6
  withBase?: boolean;
7
7
  }): string;
8
+ declare function isPathFile(path: string): boolean;
8
9
  declare function fixSlashes(trailingSlash: boolean | undefined, pathOrUrl: string): string;
9
10
 
10
- export { fixSlashes, resolveSitePath };
11
+ export { fixSlashes, isPathFile, resolveSitePath };
package/dist/urls.d.mts CHANGED
@@ -5,6 +5,7 @@ declare function resolveSitePath(pathOrUrl: string, options: {
5
5
  absolute?: boolean;
6
6
  withBase?: boolean;
7
7
  }): string;
8
+ declare function isPathFile(path: string): boolean;
8
9
  declare function fixSlashes(trailingSlash: boolean | undefined, pathOrUrl: string): string;
9
10
 
10
- export { fixSlashes, resolveSitePath };
11
+ export { fixSlashes, isPathFile, resolveSitePath };
package/dist/urls.d.ts CHANGED
@@ -5,6 +5,7 @@ declare function resolveSitePath(pathOrUrl: string, options: {
5
5
  absolute?: boolean;
6
6
  withBase?: boolean;
7
7
  }): string;
8
+ declare function isPathFile(path: string): boolean;
8
9
  declare function fixSlashes(trailingSlash: boolean | undefined, pathOrUrl: string): string;
9
10
 
10
- export { fixSlashes, resolveSitePath };
11
+ export { fixSlashes, isPathFile, resolveSitePath };
package/dist/urls.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { hasProtocol, parseURL, withLeadingSlash, withBase, withTrailingSlash, withoutTrailingSlash } from 'ufo';
1
+ import { hasProtocol, parseURL, withLeadingSlash, withoutTrailingSlash, withBase, withTrailingSlash } from 'ufo';
2
2
 
3
3
  function resolveSitePath(pathOrUrl, options) {
4
4
  let path = pathOrUrl;
@@ -10,18 +10,24 @@ function resolveSitePath(pathOrUrl, options) {
10
10
  if (base !== "/" && path.startsWith(base)) {
11
11
  path = path.slice(base.length);
12
12
  }
13
- const origin = options.absolute ? options.siteUrl : "";
13
+ let origin = withoutTrailingSlash(options.absolute ? options.siteUrl : "");
14
+ if (base !== "/" && origin.endsWith(base)) {
15
+ origin = origin.slice(0, origin.indexOf(base));
16
+ }
14
17
  const baseWithOrigin = options.withBase ? withBase(base, origin || "/") : origin;
15
18
  const resolvedUrl = withBase(path, baseWithOrigin);
16
19
  return path === "/" && !options.withBase ? withTrailingSlash(resolvedUrl) : fixSlashes(options.trailingSlash, resolvedUrl);
17
20
  }
21
+ function isPathFile(path) {
22
+ const lastSegment = path.split("/").pop();
23
+ return !!(lastSegment || path).match(/\.[0-9a-z]+$/i)?.[0];
24
+ }
18
25
  function fixSlashes(trailingSlash, pathOrUrl) {
19
26
  const $url = parseURL(pathOrUrl);
20
- const isFileUrl = $url.pathname.includes(".");
21
- if (isFileUrl)
27
+ if (isPathFile($url.pathname))
22
28
  return pathOrUrl;
23
29
  const fixedPath = trailingSlash ? withTrailingSlash($url.pathname) : withoutTrailingSlash($url.pathname);
24
30
  return `${$url.protocol ? `${$url.protocol}//` : ""}${$url.host || ""}${fixedPath}${$url.search || ""}${$url.hash || ""}`;
25
31
  }
26
32
 
27
- export { fixSlashes, resolveSitePath };
33
+ export { fixSlashes, isPathFile, 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.5",
4
+ "version": "3.0.7",
5
5
  "description": "Shared site configuration utilities.",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -45,7 +45,7 @@
45
45
  "ufo": "^1.5.4"
46
46
  },
47
47
  "devDependencies": {
48
- "vue": "^3.5.12"
48
+ "vue": "^3.5.13"
49
49
  },
50
50
  "scripts": {
51
51
  "lint": "eslint . --fix",