nuxt-site-config-kit 3.2.20 → 3.2.21

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/util.cjs CHANGED
@@ -3,10 +3,10 @@
3
3
  const stdEnv = require('std-env');
4
4
 
5
5
  function isLocalhostHost(host) {
6
- if (!host || host.startsWith("localhost") || host.startsWith("127."))
6
+ if (!host || host.startsWith("localhost") || host.startsWith("127.") || host.startsWith("0.0.0.0"))
7
7
  return true;
8
8
  const hostname = host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host;
9
- return hostname === "[::1]" || hostname === "::1";
9
+ return hostname === "[::1]" || hostname === "::1" || hostname === "[::]" || hostname === "::";
10
10
  }
11
11
  function extractHostname(host) {
12
12
  if (host.startsWith("[")) {
@@ -21,7 +21,12 @@ function splitHostPort(host) {
21
21
  const close = host.indexOf("]");
22
22
  const hostname = close !== -1 ? host.slice(0, close + 1) : host;
23
23
  const port = close !== -1 && host[close + 1] === ":" ? host.slice(close + 2) : "";
24
- return { host: hostname === "[::1]" ? "localhost" : hostname, port };
24
+ const normalized = hostname === "[::1]" || hostname === "[::]" ? "localhost" : hostname;
25
+ return { host: normalized, port };
26
+ }
27
+ if (host === "0.0.0.0" || host.startsWith("0.0.0.0:")) {
28
+ const i = host.indexOf(":");
29
+ return { host: "localhost", port: i !== -1 ? host.slice(i + 1) : "" };
25
30
  }
26
31
  const colonCount = host.split(":").length - 1;
27
32
  if (colonCount === 1) {
@@ -29,7 +34,8 @@ function splitHostPort(host) {
29
34
  return { host: host.slice(0, i), port: host.slice(i + 1) };
30
35
  }
31
36
  if (colonCount > 1) {
32
- return { host: host === "::1" ? "localhost" : `[${host}]`, port: "" };
37
+ const normalized = host === "::1" || host === "::" ? "localhost" : `[${host}]`;
38
+ return { host: normalized, port: "" };
33
39
  }
34
40
  return { host, port: "" };
35
41
  }
@@ -73,7 +79,7 @@ function getNitroOrigin(ctx = {}) {
73
79
  if (host.startsWith("http://") || host.startsWith("https://")) {
74
80
  protocol = host.startsWith("https://") ? "https" : "http";
75
81
  host = host.replace(/^https?:\/\//, "");
76
- } else if (!host || !isLocalhostHost(host)) {
82
+ } else if (!isDev && (!host || !isLocalhostHost(host))) {
77
83
  protocol = "https";
78
84
  }
79
85
  return `${protocol}://${host}${port ? `:${port}` : ""}/`;
package/dist/util.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { isDevelopment, env } from 'std-env';
2
2
 
3
3
  function isLocalhostHost(host) {
4
- if (!host || host.startsWith("localhost") || host.startsWith("127."))
4
+ if (!host || host.startsWith("localhost") || host.startsWith("127.") || host.startsWith("0.0.0.0"))
5
5
  return true;
6
6
  const hostname = host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host;
7
- return hostname === "[::1]" || hostname === "::1";
7
+ return hostname === "[::1]" || hostname === "::1" || hostname === "[::]" || hostname === "::";
8
8
  }
9
9
  function extractHostname(host) {
10
10
  if (host.startsWith("[")) {
@@ -19,7 +19,12 @@ function splitHostPort(host) {
19
19
  const close = host.indexOf("]");
20
20
  const hostname = close !== -1 ? host.slice(0, close + 1) : host;
21
21
  const port = close !== -1 && host[close + 1] === ":" ? host.slice(close + 2) : "";
22
- return { host: hostname === "[::1]" ? "localhost" : hostname, port };
22
+ const normalized = hostname === "[::1]" || hostname === "[::]" ? "localhost" : hostname;
23
+ return { host: normalized, port };
24
+ }
25
+ if (host === "0.0.0.0" || host.startsWith("0.0.0.0:")) {
26
+ const i = host.indexOf(":");
27
+ return { host: "localhost", port: i !== -1 ? host.slice(i + 1) : "" };
23
28
  }
24
29
  const colonCount = host.split(":").length - 1;
25
30
  if (colonCount === 1) {
@@ -27,7 +32,8 @@ function splitHostPort(host) {
27
32
  return { host: host.slice(0, i), port: host.slice(i + 1) };
28
33
  }
29
34
  if (colonCount > 1) {
30
- return { host: host === "::1" ? "localhost" : `[${host}]`, port: "" };
35
+ const normalized = host === "::1" || host === "::" ? "localhost" : `[${host}]`;
36
+ return { host: normalized, port: "" };
31
37
  }
32
38
  return { host, port: "" };
33
39
  }
@@ -71,7 +77,7 @@ function getNitroOrigin(ctx = {}) {
71
77
  if (host.startsWith("http://") || host.startsWith("https://")) {
72
78
  protocol = host.startsWith("https://") ? "https" : "http";
73
79
  host = host.replace(/^https?:\/\//, "");
74
- } else if (!host || !isLocalhostHost(host)) {
80
+ } else if (!isDev && (!host || !isLocalhostHost(host))) {
75
81
  protocol = "https";
76
82
  }
77
83
  return `${protocol}://${host}${port ? `:${port}` : ""}/`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-site-config-kit",
3
3
  "type": "module",
4
- "version": "3.2.20",
4
+ "version": "3.2.21",
5
5
  "description": "Shared site configuration build-time utilities for Nuxt 3 modules.",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -46,7 +46,7 @@
46
46
  "pkg-types": "^2.3.0",
47
47
  "std-env": "^3.10.0",
48
48
  "ufo": "^1.6.3",
49
- "site-config-stack": "3.2.20"
49
+ "site-config-stack": "3.2.21"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@nuxt/schema": "^4.3.1"