fix(release-cleanup): 去除 server URL 結尾斜線並驗證 release id 為正整數

- loadConfig 去除 GITEA_SERVER_URL 結尾的 /,避免拼出 //api/v1 錯誤路徑
- cleanupReleases 要求 id 為正整數,非整數一律略過(縱深防禦,不僅依賴編碼)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeffery
2026-06-26 13:55:48 +08:00
co-authored by Claude Opus 4.8
parent 888edfea27
commit 353a6af7c3
2 changed files with 8 additions and 4 deletions
+4 -1
View File
@@ -26,7 +26,10 @@ import { section, info, warn } from './logger.js'
export function loadConfig(env = process.env) {
section('參數檢查')
const serverUrl = env.GITEA_SERVER_URL
// 去除結尾多餘的 /,避免後續拼接出 `https://host//api/v1/...` 這類錯誤路徑。
const rawServerUrl = env.GITEA_SERVER_URL
const serverUrl =
typeof rawServerUrl === 'string' ? rawServerUrl.replace(/\/+$/, '') : rawServerUrl
const repository = env.GITEA_REPOSITORY
const keepCountRaw = env.KEEP_COUNT
const token = env.GITEA_TOKEN