fix(fal-image): normalize fullwidth colon in API credentials
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-02-20 19:46:43 +08:00
parent c91486e1bb
commit 32d6d10f2e

View File

@ -29,7 +29,11 @@ const DEFAULT_SAFETY_TOLERANCE = "4";
const DEFAULT_TIMEOUT_MS = 180000;
function normalizeFalCredentials(apiKey: string) {
const normalized = apiKey.replace(/\u00a0/g, " ").trim();
const normalized = apiKey
.replace(/\u00a0/g, " ")
.replace(/\u3000/g, " ")
.replace(/:/g, ":")
.trim();
const stripped = normalized.replace(/^bearer\s+/i, "").replace(/^key\s+/i, "");
const kvMatch = stripped.match(/^(?:fal[_-]?key|api[_-]?key|token)\s*[::]\s*(.+)$/i);
if (kvMatch?.[1]) {