Skip to content

Commit 760866c

Browse files
author
Changjian Wang
committed
Strip trailing slash from endpoint to prevent double-slash in URLs
1 parent 7b55d95 commit 760866c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/ContentUnderstandingClientTestBase.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ class ContentUnderstandingClientTestBase extends TestProxyTestBase {
3232

3333
@Override
3434
protected void beforeTest() {
35-
ContentUnderstandingClientBuilder contentUnderstandingClientbuilder = new ContentUnderstandingClientBuilder()
36-
.endpoint(
37-
Configuration.getGlobalConfiguration().get("AZURE_CONTENT_UNDERSTANDING_ENDPOINT", "https://localhost"))
38-
.httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null)))
39-
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
35+
String endpoint
36+
= Configuration.getGlobalConfiguration().get("AZURE_CONTENT_UNDERSTANDING_ENDPOINT", "https://localhost");
37+
// Strip trailing slash to prevent double-slash in URLs
38+
if (endpoint.endsWith("/")) {
39+
endpoint = endpoint.substring(0, endpoint.length() - 1);
40+
}
41+
42+
ContentUnderstandingClientBuilder contentUnderstandingClientbuilder
43+
= new ContentUnderstandingClientBuilder().endpoint(endpoint)
44+
.httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null)))
45+
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
4046
if (getTestMode() == TestMode.PLAYBACK) {
4147
contentUnderstandingClientbuilder.credential(new MockTokenCredential());
4248
} else if (getTestMode() == TestMode.RECORD) {

0 commit comments

Comments
 (0)