소스 검색

Fix code scanning alert no. 1: Incomplete URL substring sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
lloydchang 1 년 전
부모
커밋
7c870733a1
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      src/api/providers/openai.ts

+ 2 - 1
src/api/providers/openai.ts

@@ -17,7 +17,8 @@ export class OpenAiHandler implements ApiHandler {
 	constructor(options: ApiHandlerOptions) {
 	constructor(options: ApiHandlerOptions) {
 		this.options = options
 		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
 		// 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({
 			this.client = new AzureOpenAI({
 				baseURL: this.options.openAiBaseUrl,
 				baseURL: this.options.openAiBaseUrl,
 				apiKey: this.options.openAiApiKey,
 				apiKey: this.options.openAiApiKey,