@@ -46,6 +46,11 @@ export interface IBanditParametersResponse {
4646 bandits : Record < string , BanditParameters > ;
4747}
4848
49+ const urlWithNoTrailingSlash = ( url : URL ) => {
50+ url . pathname = url . pathname . replace ( / \/ $ / , '' ) ;
51+ return url . toString ( ) ;
52+ } ;
53+
4954export interface IHttpClient {
5055 getUniversalFlagConfiguration ( ) : Promise < IUniversalFlagConfigResponse | undefined > ;
5156 getBanditParameters ( ) : Promise < IBanditParametersResponse | undefined > ;
@@ -89,7 +94,7 @@ export default class FetchHttpClient implements IHttpClient {
8994 const controller = new AbortController ( ) ;
9095 const signal = controller . signal ;
9196 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , this . timeout ) ;
92- const response = await fetch ( url . toString ( ) , { signal } ) ;
97+ const response = await fetch ( urlWithNoTrailingSlash ( url ) , { signal } ) ;
9398 // Clear timeout when response is received within the budget.
9499 clearTimeout ( timeoutId ) ;
95100
@@ -114,7 +119,7 @@ export default class FetchHttpClient implements IHttpClient {
114119 const signal = controller . signal ;
115120 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , this . timeout ) ;
116121
117- const response = await fetch ( url . toString ( ) , {
122+ const response = await fetch ( urlWithNoTrailingSlash ( url ) , {
118123 method : 'POST' ,
119124 headers : {
120125 'Content-Type' : 'application/json' ,
0 commit comments