@@ -46,26 +46,14 @@ export interface IBanditParametersResponse {
4646 bandits : Record < string , BanditParameters > ;
4747}
4848
49- /**
50- * Fixes issues with url.toString() in older React Native versions
51- * that leaves a trailing slash in pathname
52- * @param url URL to stringify
53- * @returns stringified url
54- */
55- const urlWithNoTrailingSlash = ( url : URL ) => {
56- // Note: URL.pathname does not exist in some React Native JS runtime
57- // so we have to do string manipulation on the stringified URL
58- return url . toString ( ) . replace ( / \/ \? / , '?' ) . replace ( / \/ $ / , '' ) ;
59- } ;
60-
6149export interface IHttpClient {
6250 getUniversalFlagConfiguration ( ) : Promise < IUniversalFlagConfigResponse | undefined > ;
6351 getBanditParameters ( ) : Promise < IBanditParametersResponse | undefined > ;
6452 getPrecomputedFlags (
6553 payload : PrecomputedFlagsPayload ,
6654 ) : Promise < IObfuscatedPrecomputedConfigurationResponse | undefined > ;
67- rawGet < T > ( url : URL ) : Promise < T | undefined > ;
68- rawPost < T , P > ( url : URL , payload : P ) : Promise < T | undefined > ;
55+ rawGet < T > ( url : string ) : Promise < T | undefined > ;
56+ rawPost < T , P > ( url : string , payload : P ) : Promise < T | undefined > ;
6957}
7058
7159export default class FetchHttpClient implements IHttpClient {
@@ -94,14 +82,14 @@ export default class FetchHttpClient implements IHttpClient {
9482 ) ;
9583 }
9684
97- async rawGet < T > ( url : URL ) : Promise < T | undefined > {
85+ async rawGet < T > ( url : string ) : Promise < T | undefined > {
9886 try {
9987 // Canonical implementation of abortable fetch for interrupting when request takes longer than desired.
10088 // https://developer.chrome.com/blog/abortable-fetch/#reacting_to_an_aborted_fetch
10189 const controller = new AbortController ( ) ;
10290 const signal = controller . signal ;
10391 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , this . timeout ) ;
104- const response = await fetch ( urlWithNoTrailingSlash ( url ) , { signal } ) ;
92+ const response = await fetch ( url , { signal } ) ;
10593 // Clear timeout when response is received within the budget.
10694 clearTimeout ( timeoutId ) ;
10795
@@ -120,13 +108,13 @@ export default class FetchHttpClient implements IHttpClient {
120108 }
121109 }
122110
123- async rawPost < T , P > ( url : URL , payload : P ) : Promise < T | undefined > {
111+ async rawPost < T , P > ( url : string , payload : P ) : Promise < T | undefined > {
124112 try {
125113 const controller = new AbortController ( ) ;
126114 const signal = controller . signal ;
127115 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , this . timeout ) ;
128116
129- const response = await fetch ( urlWithNoTrailingSlash ( url ) , {
117+ const response = await fetch ( url , {
130118 method : 'POST' ,
131119 headers : {
132120 'Content-Type' : 'application/json' ,
0 commit comments