File tree 2 files changed +19
-1
lines changed
main/kotlin/com/openai/core
test/kotlin/com/openai/core
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 {
93
93
internal fun isAzureEndpoint (baseUrl : String ): Boolean {
94
94
// Azure Endpoint should be in the format of `https://<region>.openai.azure.com`.
95
95
// 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 )
97
99
}
98
100
99
101
internal interface Enum
Original file line number Diff line number Diff line change @@ -30,4 +30,20 @@ internal class UtilsTest {
30
30
assertThat(arrayOf(byteArrayOf(1 , 2 ), byteArrayOf(3 )).contentToString())
31
31
.isEqualTo(" [[1, 2], [3]]" )
32
32
}
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
+ }
33
49
}
You can’t perform that action at this time.
0 commit comments