nuxt-site-config-kit 3.2.18 → 3.2.20
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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{nuxt-site-config-kit.CNTokPxh.mjs → nuxt-site-config-kit.Bk-djAYB.mjs} +3 -3
- package/dist/shared/{nuxt-site-config-kit.DmVknu3-.cjs → nuxt-site-config-kit.C9rm3WhC.cjs} +2 -2
- package/dist/urls.cjs +1 -1
- package/dist/urls.mjs +1 -1
- package/dist/util.cjs +39 -10
- package/dist/util.mjs +39 -10
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as createSitePathResolver, g as getSiteConfigStack, i as initSiteConfig, a as installNuxtSiteConfig, u as updateSiteConfig, b as useSiteConfig, w as withSiteTrailingSlash, d as withSiteUrl } from './shared/nuxt-site-config-kit.
|
|
1
|
+
export { c as createSitePathResolver, g as getSiteConfigStack, i as initSiteConfig, a as installNuxtSiteConfig, u as updateSiteConfig, b as useSiteConfig, w as withSiteTrailingSlash, d as withSiteUrl } from './shared/nuxt-site-config-kit.Bk-djAYB.mjs';
|
|
2
2
|
export { getNitroOrigin, useNitroOrigin } from './util.mjs';
|
|
3
3
|
import '@nuxt/kit';
|
|
4
4
|
import 'site-config-stack/urls';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tryUseNuxt, installModule, resolvePath, useNuxt } from '@nuxt/kit';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveSitePath, fixSlashes } from 'site-config-stack/urls';
|
|
3
3
|
import { env } from 'std-env';
|
|
4
4
|
import { readPackageJSON } from 'pkg-types';
|
|
5
5
|
import { createSiteConfigStack, envSiteConfig } from 'site-config-stack';
|
|
@@ -62,7 +62,7 @@ async function initSiteConfig(nuxt = tryUseNuxt()) {
|
|
|
62
62
|
siteConfig.push({
|
|
63
63
|
_context: "buildEnv",
|
|
64
64
|
_priority: -1,
|
|
65
|
-
...envSiteConfig(process.env)
|
|
65
|
+
...envSiteConfig(process.env || {})
|
|
66
66
|
});
|
|
67
67
|
nuxt._siteConfig = siteConfig;
|
|
68
68
|
return siteConfig;
|
|
@@ -110,7 +110,7 @@ function withSiteUrl(path, options = {}) {
|
|
|
110
110
|
if (!siteConfig.url && options.throwErrorOnMissingSiteUrl)
|
|
111
111
|
throw new Error("Missing url in site config. Please add `{ site: { url: <url> } }` to nuxt.config.ts.");
|
|
112
112
|
const nuxt = useNuxt();
|
|
113
|
-
const base = nuxt.options.app.baseURL ||
|
|
113
|
+
const base = nuxt.options.app.baseURL || "/";
|
|
114
114
|
return resolveSitePath(path, {
|
|
115
115
|
absolute: true,
|
|
116
116
|
siteUrl: siteConfig.url || "",
|
|
@@ -64,7 +64,7 @@ async function initSiteConfig(nuxt = kit.tryUseNuxt()) {
|
|
|
64
64
|
siteConfig.push({
|
|
65
65
|
_context: "buildEnv",
|
|
66
66
|
_priority: -1,
|
|
67
|
-
...siteConfigStack.envSiteConfig(process.env)
|
|
67
|
+
...siteConfigStack.envSiteConfig(process.env || {})
|
|
68
68
|
});
|
|
69
69
|
nuxt._siteConfig = siteConfig;
|
|
70
70
|
return siteConfig;
|
|
@@ -112,7 +112,7 @@ function withSiteUrl(path, options = {}) {
|
|
|
112
112
|
if (!siteConfig.url && options.throwErrorOnMissingSiteUrl)
|
|
113
113
|
throw new Error("Missing url in site config. Please add `{ site: { url: <url> } }` to nuxt.config.ts.");
|
|
114
114
|
const nuxt = kit.useNuxt();
|
|
115
|
-
const base = nuxt.options.app.baseURL ||
|
|
115
|
+
const base = nuxt.options.app.baseURL || "/";
|
|
116
116
|
return urls.resolveSitePath(path, {
|
|
117
117
|
absolute: true,
|
|
118
118
|
siteUrl: siteConfig.url || "",
|
package/dist/urls.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require('@nuxt/kit');
|
|
4
4
|
require('site-config-stack/urls');
|
|
5
5
|
require('std-env');
|
|
6
|
-
const urls = require('./shared/nuxt-site-config-kit.
|
|
6
|
+
const urls = require('./shared/nuxt-site-config-kit.C9rm3WhC.cjs');
|
|
7
7
|
require('./util.cjs');
|
|
8
8
|
require('pkg-types');
|
|
9
9
|
require('site-config-stack');
|
package/dist/urls.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@nuxt/kit';
|
|
2
2
|
import 'site-config-stack/urls';
|
|
3
3
|
import 'std-env';
|
|
4
|
-
export { c as createSitePathResolver, w as withSiteTrailingSlash, d as withSiteUrl } from './shared/nuxt-site-config-kit.
|
|
4
|
+
export { c as createSitePathResolver, w as withSiteTrailingSlash, d as withSiteUrl } from './shared/nuxt-site-config-kit.Bk-djAYB.mjs';
|
|
5
5
|
import './util.mjs';
|
|
6
6
|
import 'pkg-types';
|
|
7
7
|
import 'site-config-stack';
|
package/dist/util.cjs
CHANGED
|
@@ -2,6 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
const stdEnv = require('std-env');
|
|
4
4
|
|
|
5
|
+
function isLocalhostHost(host) {
|
|
6
|
+
if (!host || host.startsWith("localhost") || host.startsWith("127."))
|
|
7
|
+
return true;
|
|
8
|
+
const hostname = host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host;
|
|
9
|
+
return hostname === "[::1]" || hostname === "::1";
|
|
10
|
+
}
|
|
11
|
+
function extractHostname(host) {
|
|
12
|
+
if (host.startsWith("[")) {
|
|
13
|
+
const close = host.indexOf("]");
|
|
14
|
+
return close !== -1 ? host.slice(0, close + 1) : host;
|
|
15
|
+
}
|
|
16
|
+
const colonCount = host.split(":").length - 1;
|
|
17
|
+
return colonCount === 1 ? host.slice(0, host.indexOf(":")) : host;
|
|
18
|
+
}
|
|
19
|
+
function splitHostPort(host) {
|
|
20
|
+
if (host.startsWith("[")) {
|
|
21
|
+
const close = host.indexOf("]");
|
|
22
|
+
const hostname = close !== -1 ? host.slice(0, close + 1) : host;
|
|
23
|
+
const port = close !== -1 && host[close + 1] === ":" ? host.slice(close + 2) : "";
|
|
24
|
+
return { host: hostname === "[::1]" ? "localhost" : hostname, port };
|
|
25
|
+
}
|
|
26
|
+
const colonCount = host.split(":").length - 1;
|
|
27
|
+
if (colonCount === 1) {
|
|
28
|
+
const i = host.indexOf(":");
|
|
29
|
+
return { host: host.slice(0, i), port: host.slice(i + 1) };
|
|
30
|
+
}
|
|
31
|
+
if (colonCount > 1) {
|
|
32
|
+
return { host: host === "::1" ? "localhost" : `[${host}]`, port: "" };
|
|
33
|
+
}
|
|
34
|
+
return { host, port: "" };
|
|
35
|
+
}
|
|
5
36
|
function getNitroOrigin(ctx = {}) {
|
|
6
37
|
const isDev = ctx.isDev ?? stdEnv.isDevelopment;
|
|
7
38
|
const isPrerender = ctx.isPrerender ?? !!stdEnv.env.prerender;
|
|
@@ -17,10 +48,9 @@ function getNitroOrigin(ctx = {}) {
|
|
|
17
48
|
protocol = origin.startsWith("https") ? "https" : "http";
|
|
18
49
|
}
|
|
19
50
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (reqHost && !reqHost.startsWith("localhost") && !reqHost.startsWith("127.")) {
|
|
51
|
+
if (isDev && isLocalhostHost(host) && ctx.requestHost) {
|
|
52
|
+
const reqHost = extractHostname(ctx.requestHost);
|
|
53
|
+
if (reqHost && !isLocalhostHost(reqHost)) {
|
|
24
54
|
host = ctx.requestHost;
|
|
25
55
|
protocol = ctx.requestProtocol || protocol;
|
|
26
56
|
}
|
|
@@ -34,17 +64,16 @@ function getNitroOrigin(ctx = {}) {
|
|
|
34
64
|
if (isDev)
|
|
35
65
|
port = stdEnv.env.NITRO_PORT || stdEnv.env.PORT || "3000";
|
|
36
66
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
67
|
+
const split = splitHostPort(host);
|
|
68
|
+
host = split.host;
|
|
69
|
+
if (split.port)
|
|
70
|
+
port = split.port;
|
|
42
71
|
host = stdEnv.env.NUXT_SITE_HOST_OVERRIDE || host;
|
|
43
72
|
port = stdEnv.env.NUXT_SITE_PORT_OVERRIDE || port;
|
|
44
73
|
if (host.startsWith("http://") || host.startsWith("https://")) {
|
|
45
74
|
protocol = host.startsWith("https://") ? "https" : "http";
|
|
46
75
|
host = host.replace(/^https?:\/\//, "");
|
|
47
|
-
} else if (!host
|
|
76
|
+
} else if (!host || !isLocalhostHost(host)) {
|
|
48
77
|
protocol = "https";
|
|
49
78
|
}
|
|
50
79
|
return `${protocol}://${host}${port ? `:${port}` : ""}/`;
|
package/dist/util.mjs
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import { isDevelopment, env } from 'std-env';
|
|
2
2
|
|
|
3
|
+
function isLocalhostHost(host) {
|
|
4
|
+
if (!host || host.startsWith("localhost") || host.startsWith("127."))
|
|
5
|
+
return true;
|
|
6
|
+
const hostname = host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host;
|
|
7
|
+
return hostname === "[::1]" || hostname === "::1";
|
|
8
|
+
}
|
|
9
|
+
function extractHostname(host) {
|
|
10
|
+
if (host.startsWith("[")) {
|
|
11
|
+
const close = host.indexOf("]");
|
|
12
|
+
return close !== -1 ? host.slice(0, close + 1) : host;
|
|
13
|
+
}
|
|
14
|
+
const colonCount = host.split(":").length - 1;
|
|
15
|
+
return colonCount === 1 ? host.slice(0, host.indexOf(":")) : host;
|
|
16
|
+
}
|
|
17
|
+
function splitHostPort(host) {
|
|
18
|
+
if (host.startsWith("[")) {
|
|
19
|
+
const close = host.indexOf("]");
|
|
20
|
+
const hostname = close !== -1 ? host.slice(0, close + 1) : host;
|
|
21
|
+
const port = close !== -1 && host[close + 1] === ":" ? host.slice(close + 2) : "";
|
|
22
|
+
return { host: hostname === "[::1]" ? "localhost" : hostname, port };
|
|
23
|
+
}
|
|
24
|
+
const colonCount = host.split(":").length - 1;
|
|
25
|
+
if (colonCount === 1) {
|
|
26
|
+
const i = host.indexOf(":");
|
|
27
|
+
return { host: host.slice(0, i), port: host.slice(i + 1) };
|
|
28
|
+
}
|
|
29
|
+
if (colonCount > 1) {
|
|
30
|
+
return { host: host === "::1" ? "localhost" : `[${host}]`, port: "" };
|
|
31
|
+
}
|
|
32
|
+
return { host, port: "" };
|
|
33
|
+
}
|
|
3
34
|
function getNitroOrigin(ctx = {}) {
|
|
4
35
|
const isDev = ctx.isDev ?? isDevelopment;
|
|
5
36
|
const isPrerender = ctx.isPrerender ?? !!env.prerender;
|
|
@@ -15,10 +46,9 @@ function getNitroOrigin(ctx = {}) {
|
|
|
15
46
|
protocol = origin.startsWith("https") ? "https" : "http";
|
|
16
47
|
}
|
|
17
48
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (reqHost && !reqHost.startsWith("localhost") && !reqHost.startsWith("127.")) {
|
|
49
|
+
if (isDev && isLocalhostHost(host) && ctx.requestHost) {
|
|
50
|
+
const reqHost = extractHostname(ctx.requestHost);
|
|
51
|
+
if (reqHost && !isLocalhostHost(reqHost)) {
|
|
22
52
|
host = ctx.requestHost;
|
|
23
53
|
protocol = ctx.requestProtocol || protocol;
|
|
24
54
|
}
|
|
@@ -32,17 +62,16 @@ function getNitroOrigin(ctx = {}) {
|
|
|
32
62
|
if (isDev)
|
|
33
63
|
port = env.NITRO_PORT || env.PORT || "3000";
|
|
34
64
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
65
|
+
const split = splitHostPort(host);
|
|
66
|
+
host = split.host;
|
|
67
|
+
if (split.port)
|
|
68
|
+
port = split.port;
|
|
40
69
|
host = env.NUXT_SITE_HOST_OVERRIDE || host;
|
|
41
70
|
port = env.NUXT_SITE_PORT_OVERRIDE || port;
|
|
42
71
|
if (host.startsWith("http://") || host.startsWith("https://")) {
|
|
43
72
|
protocol = host.startsWith("https://") ? "https" : "http";
|
|
44
73
|
host = host.replace(/^https?:\/\//, "");
|
|
45
|
-
} else if (!host
|
|
74
|
+
} else if (!host || !isLocalhostHost(host)) {
|
|
46
75
|
protocol = "https";
|
|
47
76
|
}
|
|
48
77
|
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.
|
|
4
|
+
"version": "3.2.20",
|
|
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",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"util.d.ts"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@nuxt/kit": "^4.
|
|
45
|
+
"@nuxt/kit": "^4.3.1",
|
|
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.
|
|
49
|
+
"site-config-stack": "3.2.20"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@nuxt/schema": "^4.
|
|
52
|
+
"@nuxt/schema": "^4.3.1"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"lint": "eslint . --fix",
|