Merge pull request #66 from RooVetGit/alert-autofix-1

Fix code scanning alert no. 1: Incomplete URL substring sanitization
This commit is contained in:
Matt Rubens 2024-12-11 13:03:55 -05:00 committed by GitHub
commit 20c7c575e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,7 +17,8 @@ export class OpenAiHandler implements ApiHandler {
constructor(options: ApiHandlerOptions) {
this.options = options
// Azure API shape slightly differs from the core API shape: https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
if (this.options.openAiBaseUrl?.toLowerCase().includes("azure.com")) {
const urlHost = new URL(this.options.openAiBaseUrl ?? "").host;
if (urlHost === "azure.com" || urlHost.endsWith(".azure.com")) {
this.client = new AzureOpenAI({
baseURL: this.options.openAiBaseUrl,
apiKey: this.options.openAiApiKey,