@oktis-works/admin 0.4.6 → 0.4.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/dist/client/_astro/{AtGlanceWidget.Cq8OOJPG.js → AtGlanceWidget.Csh6O1qC.js} +1 -1
- package/dist/client/_astro/{Footer.BU0nQfsj.js → Footer.B45KEgQC.js} +1 -1
- package/dist/client/_astro/{QuickDraftWidget.BklxPtXw.js → QuickDraftWidget.DsmDxcjM.js} +1 -1
- package/dist/client/_astro/{version.BBlB8V1z.js → version.DLKCNYBX.js} +1 -1
- package/dist/server/chunks/{ContentEditor_BIKFMKGc.mjs → ContentEditor_DYVCMTXI.mjs} +2 -1
- package/dist/server/chunks/{DashboardLayout_DvpIbi-L.mjs → DashboardLayout_BSI1WOi6.mjs} +3 -519
- package/dist/server/chunks/{MediaLibrary_ayG_it4q.mjs → MediaLibrary_DZjpMXgK.mjs} +2 -1
- package/dist/server/chunks/{_slug__DGHktOQk.mjs → _slug__CT9lqK13.mjs} +1 -1
- package/dist/server/chunks/{edit_zoYziljx.mjs → edit_BUOEvmvl.mjs} +2 -2
- package/dist/server/chunks/{general_CBOFvXp5.mjs → general_pGxOJQzX.mjs} +2 -1
- package/dist/server/chunks/i18n_DnHqy5K-.mjs +527 -0
- package/dist/server/chunks/{index_D6HRv5gR.mjs → index_BSxjpQXZ.mjs} +2 -1
- package/dist/server/chunks/{index_BGAjNTWX.mjs → index_CHL9vq3T.mjs} +2 -1
- package/dist/server/chunks/{index_DXH9TpQZ.mjs → index_DgL2eLJu.mjs} +2 -1
- package/dist/server/chunks/{index_B0Kv_zY5.mjs → index_IW6nshbT.mjs} +2 -2
- package/dist/server/chunks/{index_B9j_Mdp1.mjs → index_YwwAn3Lb.mjs} +1 -1
- package/dist/server/chunks/{new_BGsvWic-.mjs → new_BfiBbnro.mjs} +2 -2
- package/dist/server/chunks/{new_1yZE_PrZ.mjs → new_D1aZllsr.mjs} +2 -1
- package/dist/server/chunks/{node_BafXIcNi.mjs → node_kWZa8y--.mjs} +3 -3
- package/dist/server/chunks/{post-types_9hCXqS5l.mjs → post-types_76cyJz6s.mjs} +2 -1
- package/dist/server/chunks/remote_ByPF9VwL.mjs +49 -0
- package/dist/server/chunks/sequence_CQpaaIXP.mjs +1420 -0
- package/dist/server/chunks/{sharp_C91d8fsK.mjs → sharp_37gnUicY.mjs} +1 -1
- package/dist/server/chunks/{taxonomies_CzecicEb.mjs → taxonomies_DFQu9XsS.mjs} +2 -1
- package/dist/server/chunks/{upload_BaboNcp0.mjs → upload_39j7H3EB.mjs} +2 -2
- package/dist/server/entry.mjs +23 -1151
- package/dist/server/virtual_astro_middleware.mjs +56 -2
- package/package.json +1 -1
- package/dist/server/chunks/console_B_CnzVJ2.mjs +0 -170
- package/dist/server/chunks/remote_DUw5DMmE.mjs +0 -169
|
@@ -1,4 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { K as defineMiddleware, t as sequence } from "./chunks/sequence_CQpaaIXP.mjs";
|
|
2
|
+
import { o as SUPPORTED_LOCALES, s as isRTLLocale, t as getTranslationsForLocale } from "./chunks/i18n_DnHqy5K-.mjs";
|
|
3
|
+
//#region src/middleware.ts
|
|
4
|
+
function createTFunctionFromMap(map, fallback) {
|
|
5
|
+
return (key, params) => {
|
|
6
|
+
const keys = key.split(".");
|
|
7
|
+
let value = map;
|
|
8
|
+
for (const k of keys) if (value && typeof value === "object" && k in value) value = value[k];
|
|
9
|
+
else {
|
|
10
|
+
value = fallback;
|
|
11
|
+
for (const k2 of keys) if (value && typeof value === "object" && k2 in value) value = value[k2];
|
|
12
|
+
else return key;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value !== "string") return key;
|
|
16
|
+
if (params) return value.replace(/\{(\w+)\}/g, (_, p) => String(params[p] ?? ""));
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createFallbackT() {
|
|
21
|
+
return (key) => key;
|
|
22
|
+
}
|
|
23
|
+
var onRequest$1 = defineMiddleware(async (context, next) => {
|
|
24
|
+
context.locals.t = createFallbackT();
|
|
25
|
+
context.locals.locale = "en";
|
|
26
|
+
context.locals.isRTL = false;
|
|
27
|
+
try {
|
|
28
|
+
const cookieLocale = context.cookies.get("admin_locale")?.value;
|
|
29
|
+
let userLocale = null;
|
|
30
|
+
try {
|
|
31
|
+
const res = await fetch(`http://localhost:3000/api/v1/users/me/locale`, {
|
|
32
|
+
credentials: "include",
|
|
33
|
+
headers: { Cookie: context.request.headers.get("Cookie") ?? "" }
|
|
34
|
+
});
|
|
35
|
+
if (res.ok) userLocale = (await res.json()).locale;
|
|
36
|
+
} catch {}
|
|
37
|
+
const browserLocale = context.request.headers.get("Accept-Language")?.split(",")[0]?.split("-")[0] ?? "en";
|
|
38
|
+
const locale = cookieLocale ?? userLocale ?? browserLocale;
|
|
39
|
+
const validLocale = SUPPORTED_LOCALES.includes(locale) ? locale : "en";
|
|
40
|
+
const [translations, fallback] = await Promise.all([getTranslationsForLocale(validLocale), getTranslationsForLocale("en")]);
|
|
41
|
+
context.locals.t = createTFunctionFromMap(translations, fallback);
|
|
42
|
+
context.locals.locale = validLocale;
|
|
43
|
+
context.locals.isRTL = isRTLLocale(validLocale);
|
|
44
|
+
if (!cookieLocale) context.cookies.set("admin_locale", validLocale, {
|
|
45
|
+
path: "/",
|
|
46
|
+
maxAge: 31536e3,
|
|
47
|
+
sameSite: "lax"
|
|
48
|
+
});
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.warn("[i18n middleware] fallback ativo:", e instanceof Error ? e.message : e);
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region \0virtual:astro:middleware
|
|
56
|
+
var onRequest = sequence(onRequest$1);
|
|
3
57
|
//#endregion
|
|
4
58
|
export { onRequest };
|
package/package.json
CHANGED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { T as s } from "./server_B5N27szj.mjs";
|
|
2
|
-
//#region ../../node_modules/.bun/astro@7.3.5+3335b8e0b249efdf/node_modules/astro/dist/core/logger/core.js
|
|
3
|
-
var dateTimeFormat = new Intl.DateTimeFormat([], {
|
|
4
|
-
hour: "2-digit",
|
|
5
|
-
minute: "2-digit",
|
|
6
|
-
second: "2-digit",
|
|
7
|
-
hour12: false
|
|
8
|
-
});
|
|
9
|
-
var levels = {
|
|
10
|
-
debug: 20,
|
|
11
|
-
info: 30,
|
|
12
|
-
warn: 40,
|
|
13
|
-
error: 50,
|
|
14
|
-
silent: 90
|
|
15
|
-
};
|
|
16
|
-
function log(opts, level, label, message, newLine = true) {
|
|
17
|
-
const logLevel = opts.level;
|
|
18
|
-
const dest = opts.destination;
|
|
19
|
-
const event = {
|
|
20
|
-
label,
|
|
21
|
-
level,
|
|
22
|
-
message,
|
|
23
|
-
newLine
|
|
24
|
-
};
|
|
25
|
-
if (!isLogLevelEnabled(logLevel, level)) return;
|
|
26
|
-
dest.write(event);
|
|
27
|
-
}
|
|
28
|
-
function isLogLevelEnabled(configuredLogLevel, level) {
|
|
29
|
-
return levels[configuredLogLevel] <= levels[level];
|
|
30
|
-
}
|
|
31
|
-
function info(opts, label, message, newLine = true) {
|
|
32
|
-
return log(opts, "info", label, message, newLine);
|
|
33
|
-
}
|
|
34
|
-
function warn(opts, label, message, newLine = true) {
|
|
35
|
-
return log(opts, "warn", label, message, newLine);
|
|
36
|
-
}
|
|
37
|
-
function error(opts, label, message, newLine = true) {
|
|
38
|
-
return log(opts, "error", label, message, newLine);
|
|
39
|
-
}
|
|
40
|
-
function debug(...args) {
|
|
41
|
-
if ("_astroGlobalDebug" in globalThis) globalThis._astroGlobalDebug(...args);
|
|
42
|
-
}
|
|
43
|
-
function getEventPrefix({ level, label }) {
|
|
44
|
-
const timestamp = `${dateTimeFormat.format(/* @__PURE__ */ new Date())}`;
|
|
45
|
-
const prefix = [];
|
|
46
|
-
if (level === "error" || level === "warn") {
|
|
47
|
-
prefix.push(s.bold(timestamp));
|
|
48
|
-
prefix.push(`[${level.toUpperCase()}]`);
|
|
49
|
-
} else prefix.push(timestamp);
|
|
50
|
-
if (label) prefix.push(`[${label}]`);
|
|
51
|
-
if (level === "error") return s.red(prefix.join(" "));
|
|
52
|
-
if (level === "warn") return s.yellow(prefix.join(" "));
|
|
53
|
-
if (prefix.length === 1) return s.dim(prefix[0]);
|
|
54
|
-
return s.dim(prefix[0]) + " " + s.blue(prefix.splice(1).join(" "));
|
|
55
|
-
}
|
|
56
|
-
var AstroLogger = class {
|
|
57
|
-
options;
|
|
58
|
-
constructor(options) {
|
|
59
|
-
this.options = options;
|
|
60
|
-
}
|
|
61
|
-
info(label, message, newLine = true) {
|
|
62
|
-
info(this.options, label, message, newLine);
|
|
63
|
-
}
|
|
64
|
-
warn(label, message, newLine = true) {
|
|
65
|
-
warn(this.options, label, message, newLine);
|
|
66
|
-
}
|
|
67
|
-
error(label, message, newLine = true) {
|
|
68
|
-
error(this.options, label, message, newLine);
|
|
69
|
-
}
|
|
70
|
-
debug(label, ...messages) {
|
|
71
|
-
debug(label, ...messages);
|
|
72
|
-
}
|
|
73
|
-
level() {
|
|
74
|
-
return this.options.level;
|
|
75
|
-
}
|
|
76
|
-
forkIntegrationLogger(label) {
|
|
77
|
-
return new AstroIntegrationLogger(this.options, label);
|
|
78
|
-
}
|
|
79
|
-
setDestination(destination) {
|
|
80
|
-
this.options.destination = destination;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* It calls the `close` function of the provided destination, if it exists.
|
|
84
|
-
*/
|
|
85
|
-
close() {
|
|
86
|
-
if (this.options.destination.close) this.options.destination.close();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* It calls the `flush` function of the provided destination, if it exists.
|
|
90
|
-
*/
|
|
91
|
-
flush() {
|
|
92
|
-
if (this.options.destination.flush) this.options.destination.flush();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var AstroIntegrationLogger = class AstroIntegrationLogger {
|
|
96
|
-
options;
|
|
97
|
-
label;
|
|
98
|
-
constructor(logging, label) {
|
|
99
|
-
this.options = logging;
|
|
100
|
-
this.label = label;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new logger instance with a new label, but the same log options.
|
|
104
|
-
*/
|
|
105
|
-
fork(label) {
|
|
106
|
-
return new AstroIntegrationLogger(this.options, label);
|
|
107
|
-
}
|
|
108
|
-
info(message) {
|
|
109
|
-
info(this.options, this.label, message);
|
|
110
|
-
}
|
|
111
|
-
warn(message) {
|
|
112
|
-
warn(this.options, this.label, message);
|
|
113
|
-
}
|
|
114
|
-
error(message) {
|
|
115
|
-
error(this.options, this.label, message);
|
|
116
|
-
}
|
|
117
|
-
debug(message) {
|
|
118
|
-
debug(this.label, message);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* It calls the `flush` function of the provided destination, if it exists.
|
|
122
|
-
*/
|
|
123
|
-
flush() {
|
|
124
|
-
if (this.options.destination.flush) this.options.destination.flush();
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* It calls the `close` function of the provided destination, if it exists.
|
|
128
|
-
*/
|
|
129
|
-
close() {
|
|
130
|
-
if (this.options.destination.close) this.options.destination.close();
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
function astroToRuntimeLogger(logger) {
|
|
134
|
-
return {
|
|
135
|
-
info(msg) {
|
|
136
|
-
logger.info(null, msg);
|
|
137
|
-
},
|
|
138
|
-
warn(msg) {
|
|
139
|
-
logger.warn(null, msg);
|
|
140
|
-
},
|
|
141
|
-
error(msg) {
|
|
142
|
-
logger.error(null, msg);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region ../../node_modules/.bun/astro@7.3.5+3335b8e0b249efdf/node_modules/astro/dist/core/logger/public.js
|
|
148
|
-
function matchesLevel(messageLevel, configuredLevel) {
|
|
149
|
-
return levels[messageLevel] >= levels[configuredLevel];
|
|
150
|
-
}
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region ../../node_modules/.bun/astro@7.3.5+3335b8e0b249efdf/node_modules/astro/dist/core/logger/impls/console.js
|
|
153
|
-
function consoleLogDestination(config = {}) {
|
|
154
|
-
const { level = "info" } = config;
|
|
155
|
-
return { write(event) {
|
|
156
|
-
let dest = console.error;
|
|
157
|
-
if (levels[event.level] < levels["error"]) dest = console.info;
|
|
158
|
-
if (!matchesLevel(event.level, level)) return;
|
|
159
|
-
if (event.label === "SKIP_FORMAT") dest(event.message);
|
|
160
|
-
else dest(getEventPrefix(event) + " " + event.message);
|
|
161
|
-
} };
|
|
162
|
-
}
|
|
163
|
-
function createConsoleLogger({ level }) {
|
|
164
|
-
return new AstroLogger({
|
|
165
|
-
level,
|
|
166
|
-
destination: consoleLogDestination()
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
export { AstroIntegrationLogger as n, astroToRuntimeLogger as r, createConsoleLogger as t };
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@astrojs+internal-helpers@0.11.0/node_modules/@astrojs/internal-helpers/dist/path.js
|
|
2
|
-
function appendForwardSlash(path) {
|
|
3
|
-
return path.endsWith("/") ? path : path + "/";
|
|
4
|
-
}
|
|
5
|
-
function prependForwardSlash(path) {
|
|
6
|
-
return path[0] === "/" ? path : "/" + path;
|
|
7
|
-
}
|
|
8
|
-
var MANY_LEADING_SLASHES = /^\/{2,}/;
|
|
9
|
-
function collapseDuplicateLeadingSlashes(path) {
|
|
10
|
-
if (!path) return path;
|
|
11
|
-
return path.replace(MANY_LEADING_SLASHES, "/");
|
|
12
|
-
}
|
|
13
|
-
var MANY_SLASHES = /\/{2,}/g;
|
|
14
|
-
function collapseDuplicateSlashes(path) {
|
|
15
|
-
if (!path) return path;
|
|
16
|
-
return path.replace(MANY_SLASHES, "/");
|
|
17
|
-
}
|
|
18
|
-
var MANY_TRAILING_SLASHES = /\/{2,}$/g;
|
|
19
|
-
function collapseDuplicateTrailingSlashes(path, trailingSlash) {
|
|
20
|
-
if (!path) return path;
|
|
21
|
-
return path.replace(MANY_TRAILING_SLASHES, trailingSlash ? "/" : "") || "/";
|
|
22
|
-
}
|
|
23
|
-
function removeTrailingForwardSlash(path) {
|
|
24
|
-
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
|
|
25
|
-
}
|
|
26
|
-
function removeLeadingForwardSlash(path) {
|
|
27
|
-
return path.startsWith("/") ? path.substring(1) : path;
|
|
28
|
-
}
|
|
29
|
-
function trimSlashes(path) {
|
|
30
|
-
return path.replace(/^\/|\/$/g, "");
|
|
31
|
-
}
|
|
32
|
-
function isString(path) {
|
|
33
|
-
return typeof path === "string" || path instanceof String;
|
|
34
|
-
}
|
|
35
|
-
var INTERNAL_PREFIXES = /* @__PURE__ */ new Set([
|
|
36
|
-
"/_",
|
|
37
|
-
"/@",
|
|
38
|
-
"/.",
|
|
39
|
-
"//"
|
|
40
|
-
]);
|
|
41
|
-
var JUST_SLASHES = /^\/{2,}$/;
|
|
42
|
-
function isInternalPath(path) {
|
|
43
|
-
const prefix = path.slice(0, 2).replace(/\\/g, "/");
|
|
44
|
-
return INTERNAL_PREFIXES.has(prefix) && !JUST_SLASHES.test(path);
|
|
45
|
-
}
|
|
46
|
-
function joinPaths(...paths) {
|
|
47
|
-
return paths.filter(isString).map((path, i) => {
|
|
48
|
-
if (i === 0) return removeTrailingForwardSlash(path);
|
|
49
|
-
else if (i === paths.length - 1) return removeLeadingForwardSlash(path);
|
|
50
|
-
else return trimSlashes(path);
|
|
51
|
-
}).join("/");
|
|
52
|
-
}
|
|
53
|
-
function removeQueryString(path) {
|
|
54
|
-
const index = path.lastIndexOf("?");
|
|
55
|
-
return index > 0 ? path.substring(0, index) : path;
|
|
56
|
-
}
|
|
57
|
-
function isRemotePath(src) {
|
|
58
|
-
if (!src) return false;
|
|
59
|
-
const trimmed = src.trim();
|
|
60
|
-
if (!trimmed) return false;
|
|
61
|
-
let decoded = trimmed;
|
|
62
|
-
let previousDecoded = "";
|
|
63
|
-
let maxIterations = 10;
|
|
64
|
-
while (decoded !== previousDecoded && maxIterations > 0) {
|
|
65
|
-
previousDecoded = decoded;
|
|
66
|
-
try {
|
|
67
|
-
decoded = decodeURIComponent(decoded);
|
|
68
|
-
} catch {
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
maxIterations--;
|
|
72
|
-
}
|
|
73
|
-
if (/^[a-zA-Z]:/.test(decoded)) return false;
|
|
74
|
-
if (decoded[0] === "/" && /^\/[\w.@-]/.test(decoded)) return false;
|
|
75
|
-
if (decoded[0] === "\\") return true;
|
|
76
|
-
if (decoded.startsWith("//")) return true;
|
|
77
|
-
try {
|
|
78
|
-
const url = new URL(decoded, "http://n");
|
|
79
|
-
if (url.username || url.password) return true;
|
|
80
|
-
if (decoded.includes("@") && !url.pathname.includes("@") && !url.search.includes("@")) return true;
|
|
81
|
-
if (url.origin !== "http://n") {
|
|
82
|
-
if (url.protocol.toLowerCase() === "file:") return false;
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
if (URL.canParse(decoded)) return true;
|
|
86
|
-
return false;
|
|
87
|
-
} catch {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function isParentDirectory(parentPath, childPath) {
|
|
92
|
-
if (!parentPath || !childPath) return false;
|
|
93
|
-
if (parentPath.includes("://") || childPath.includes("://")) return false;
|
|
94
|
-
if (isRemotePath(parentPath) || isRemotePath(childPath)) return false;
|
|
95
|
-
if (parentPath.includes("..") || childPath.includes("..")) return false;
|
|
96
|
-
if (parentPath.includes("\0") || childPath.includes("\0")) return false;
|
|
97
|
-
const normalizedParent = appendForwardSlash(slash(parentPath).toLowerCase());
|
|
98
|
-
const normalizedChild = slash(childPath).toLowerCase();
|
|
99
|
-
if (normalizedParent === normalizedChild || normalizedParent === normalizedChild + "/") return false;
|
|
100
|
-
return normalizedChild.startsWith(normalizedParent);
|
|
101
|
-
}
|
|
102
|
-
function slash(path) {
|
|
103
|
-
return path.replace(/\\/g, "/");
|
|
104
|
-
}
|
|
105
|
-
function fileExtension(path) {
|
|
106
|
-
const ext = path.split(".").pop();
|
|
107
|
-
return ext !== path ? `.${ext}` : "";
|
|
108
|
-
}
|
|
109
|
-
function stripRequestBase(pathname, base) {
|
|
110
|
-
pathname = collapseDuplicateLeadingSlashes(pathname);
|
|
111
|
-
const baseWithoutTrailingSlash = removeTrailingForwardSlash(base);
|
|
112
|
-
if (pathname === baseWithoutTrailingSlash) return "/";
|
|
113
|
-
if (pathname.startsWith(baseWithoutTrailingSlash + "/")) return pathname.slice(baseWithoutTrailingSlash.length);
|
|
114
|
-
return pathname;
|
|
115
|
-
}
|
|
116
|
-
var WITH_FILE_EXT = /\/[^/]+\.\w+$/;
|
|
117
|
-
function hasFileExtension(path) {
|
|
118
|
-
return WITH_FILE_EXT.test(path);
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region ../../node_modules/.bun/@astrojs+internal-helpers@0.11.0/node_modules/@astrojs/internal-helpers/dist/remote.js
|
|
122
|
-
function matchPattern(url, remotePattern) {
|
|
123
|
-
return matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && matchPort(url, remotePattern.port) && matchPathname(url, remotePattern.pathname, true);
|
|
124
|
-
}
|
|
125
|
-
function matchPort(url, port) {
|
|
126
|
-
return !port || port === url.port;
|
|
127
|
-
}
|
|
128
|
-
function matchProtocol(url, protocol) {
|
|
129
|
-
return !protocol || protocol === url.protocol.slice(0, -1);
|
|
130
|
-
}
|
|
131
|
-
function matchHostname(url, hostname, allowWildcard = false) {
|
|
132
|
-
if (!hostname) return true;
|
|
133
|
-
else if (!allowWildcard || !hostname.startsWith("*")) return hostname === url.hostname;
|
|
134
|
-
else if (hostname.startsWith("**.")) {
|
|
135
|
-
const slicedHostname = hostname.slice(2);
|
|
136
|
-
return slicedHostname !== url.hostname && url.hostname.endsWith(slicedHostname);
|
|
137
|
-
} else if (hostname.startsWith("*.")) {
|
|
138
|
-
const slicedHostname = hostname.slice(1);
|
|
139
|
-
if (!url.hostname.endsWith(slicedHostname)) return false;
|
|
140
|
-
const subdomainWithDot = url.hostname.slice(0, -(slicedHostname.length - 1));
|
|
141
|
-
return subdomainWithDot.endsWith(".") && !subdomainWithDot.slice(0, -1).includes(".");
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
function matchPathname(url, pathname, allowWildcard = false) {
|
|
146
|
-
if (!pathname) return true;
|
|
147
|
-
else if (!allowWildcard || !pathname.endsWith("*")) return pathname === url.pathname;
|
|
148
|
-
else if (pathname.endsWith("/**")) {
|
|
149
|
-
const slicedPathname = pathname.slice(0, -2);
|
|
150
|
-
return slicedPathname !== url.pathname && url.pathname.startsWith(slicedPathname);
|
|
151
|
-
} else if (pathname.endsWith("/*")) {
|
|
152
|
-
const slicedPathname = pathname.slice(0, -1);
|
|
153
|
-
if (!url.pathname.startsWith(slicedPathname)) return false;
|
|
154
|
-
return url.pathname.slice(slicedPathname.length).split("/").filter(Boolean).length === 1;
|
|
155
|
-
}
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
function isRemoteAllowed(src, { domains, remotePatterns }) {
|
|
159
|
-
if (!URL.canParse(src)) return false;
|
|
160
|
-
const url = new URL(src);
|
|
161
|
-
if (![
|
|
162
|
-
"http:",
|
|
163
|
-
"https:",
|
|
164
|
-
"data:"
|
|
165
|
-
].includes(url.protocol)) return false;
|
|
166
|
-
return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
|
-
export { slash as _, collapseDuplicateSlashes as a, hasFileExtension as c, isRemotePath as d, joinPaths as f, removeTrailingForwardSlash as g, removeQueryString as h, collapseDuplicateLeadingSlashes as i, isInternalPath as l, removeLeadingForwardSlash as m, matchPattern as n, collapseDuplicateTrailingSlashes as o, prependForwardSlash as p, appendForwardSlash as r, fileExtension as s, isRemoteAllowed as t, isParentDirectory as u, stripRequestBase as v, trimSlashes as y };
|