Skip to content

Commit 6dc21dd

Browse files
authored
fix: Network Error in older React Naitve versions (#243)
1 parent 8698727 commit 6dc21dd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eppo/js-client-sdk-common",
3-
"version": "4.13.4",
3+
"version": "4.13.5-alpha1",
44
"description": "Common library for Eppo JavaScript SDKs (web, react native, and node)",
55
"main": "dist/index.js",
66
"files": [

src/http-client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ 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+
*/
4955
const urlWithNoTrailingSlash = (url: URL) => {
50-
url.pathname = url.pathname.replace(/\/$/, '');
51-
return url.toString();
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(/\/$/, '');
5259
};
5360

5461
export interface IHttpClient {

0 commit comments

Comments
 (0)