@@ -46,6 +46,11 @@ export interface IBanditParametersResponse {
46
46
bandits : Record < string , BanditParameters > ;
47
47
}
48
48
49
+ const urlWithNoTrailingSlash = ( url : URL ) => {
50
+ url . pathname = url . pathname . replace ( / \/ $ / , '' ) ;
51
+ return url . toString ( ) ;
52
+ } ;
53
+
49
54
export interface IHttpClient {
50
55
getUniversalFlagConfiguration ( ) : Promise < IUniversalFlagConfigResponse | undefined > ;
51
56
getBanditParameters ( ) : Promise < IBanditParametersResponse | undefined > ;
@@ -89,7 +94,7 @@ export default class FetchHttpClient implements IHttpClient {
89
94
const controller = new AbortController ( ) ;
90
95
const signal = controller . signal ;
91
96
const timeoutId = setTimeout ( ( ) => controller . abort ( ) , this . timeout ) ;
92
- const response = await fetch ( url . toString ( ) , { signal } ) ;
97
+ const response = await fetch ( urlWithNoTrailingSlash ( url ) , { signal } ) ;
93
98
// Clear timeout when response is received within the budget.
94
99
clearTimeout ( timeoutId ) ;
95
100
@@ -114,7 +119,7 @@ export default class FetchHttpClient implements IHttpClient {
114
119
const signal = controller . signal ;
115
120
const timeoutId = setTimeout ( ( ) => controller . abort ( ) , this . timeout ) ;
116
121
117
- const response = await fetch ( url . toString ( ) , {
122
+ const response = await fetch ( urlWithNoTrailingSlash ( url ) , {
118
123
method : 'POST' ,
119
124
headers : {
120
125
'Content-Type' : 'application/json' ,
0 commit comments