File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
main/kotlin/com/openai/core
test/kotlin/com/openai/core Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,9 @@ internal fun Any?.contentToString(): String {
9393internal fun isAzureEndpoint (baseUrl : String ): Boolean {
9494 // Azure Endpoint should be in the format of `https://<region>.openai.azure.com`.
9595 // Or `https://<region>.azure-api.net` for Azure OpenAI Management URL.
96- return baseUrl.endsWith(" .openai.azure.com" , true ) || baseUrl.endsWith(" .azure-api.net" , true )
96+ val trimmedBaseUrl = baseUrl.trim().trimEnd(' /' )
97+ return trimmedBaseUrl.endsWith(" .openai.azure.com" , true ) ||
98+ trimmedBaseUrl.endsWith(" .azure-api.net" , true )
9799}
98100
99101internal interface Enum
Original file line number Diff line number Diff line change @@ -30,4 +30,20 @@ internal class UtilsTest {
3030 assertThat(arrayOf(byteArrayOf(1 , 2 ), byteArrayOf(3 )).contentToString())
3131 .isEqualTo(" [[1, 2], [3]]" )
3232 }
33+
34+ @Test
35+ fun isAzureEndpoint () {
36+ // Valid Azure endpoints
37+ assertThat(isAzureEndpoint(" https://region.openai.azure.com" )).isTrue()
38+ assertThat(isAzureEndpoint(" https://region.openai.azure.com/" )).isTrue()
39+ assertThat(isAzureEndpoint(" https://region.azure-api.net" )).isTrue()
40+ assertThat(isAzureEndpoint(" https://region.azure-api.net/" )).isTrue()
41+
42+ // Invalid Azure endpoints
43+ assertThat(isAzureEndpoint(" https://example.com" )).isFalse()
44+ assertThat(isAzureEndpoint(" https://region.openai.com" )).isFalse()
45+ assertThat(isAzureEndpoint(" https://region.azure.com" )).isFalse()
46+ assertThat(isAzureEndpoint(" " )).isFalse()
47+ assertThat(isAzureEndpoint(" " )).isFalse()
48+ }
3349}
You can’t perform that action at this time.
0 commit comments