fix
This commit is contained in:
1 file changed
+8
-1
+8
-1
@@ -10,8 +10,15 @@ export function loadConfig(env = process.env): Config {
|
||||
const token = env.GITEA_TOKEN?.trim();
|
||||
if (!url) throw new Error("GITEA_URL не задан (например https://gitea.example.com)");
|
||||
if (!token) throw new Error("GITEA_TOKEN не задан (Settings → Applications → Access Token)");
|
||||
const baseUrl = url.replace(/\/+$/, "").replace(/\/api\/v1$/, "");
|
||||
try {
|
||||
const { protocol } = new URL(baseUrl);
|
||||
if (protocol !== "http:" && protocol !== "https:") throw new Error();
|
||||
} catch {
|
||||
throw new Error(`GITEA_URL некорректен: "${baseUrl}" (ожидается вид https://gitea.example.com)`);
|
||||
}
|
||||
return {
|
||||
baseUrl: url.replace(/\/+$/, "").replace(/\/api\/v1$/, ""),
|
||||
baseUrl,
|
||||
token,
|
||||
readonly: /^(1|true|yes)$/i.test(env.GITEA_READONLY ?? ""),
|
||||
timeoutMs: Number(env.GITEA_TIMEOUT_MS ?? 30000),
|
||||
|
||||
Reference in new issue
Block a user