INNER CODE UNIT · JavaScript
sanitizeProviderProfile
kevinchin12/ImageLens · background.js:676
function sanitizeProviderProfile(provider, input) {
const defaults = getProviderDefaults(provider);
const merged = { ...defaults, ...(isPlainObject(input) ? input : {}) };
return {
apiMode: merged.apiMode === "proxy" ? "proxy" : "direct",
promptApiKey: String(merged.promptApiKey || ""),
promptModel: String(merged.promptModel || defaults.promptModel),
imageGenerationEnabled: Boolean(merged.imageGenerationEnabled),
imageApiKey: String(merged.imageApiKey || ""),
imageModel: String(merged.imageModel || defaults.imageModel),
geminiBaseUrl: String(merged.geminiBaseUrl || defaults.geminiBaseUrl),
openaiBaseUrl: String(merged.openaiBaseUrl || defaults.openaiBaseUrl),
customProxyUrl: String(merged.customProxyUrl || ""),
customProxyToken: String(merged.customProxyToken || ""),
autoAnalyze: Boolean(merged.autoAnalyze)
};
}