Skip to content

Commit

Permalink
Added / logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Mar 29, 2024
1 parent 67bc668 commit 127db77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Branch-SDK-TestBed/src/main/assets/branch.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{

{
"apiUrl": "https://api3.branch.io"
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void setupApiUrlText() {
apiUrlText.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_DONE) {
String newApiUrl = textView.getText().toString();
Branch.setAPIUrl("https://myapi.com/");
Branch.setAPIUrl(newApiUrl);

InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(apiUrlText.getWindowToken(), 0);
Expand Down
12 changes: 10 additions & 2 deletions Branch-SDK/src/main/java/io/branch/referral/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,16 @@ public static void expectDelayedSessionInitialization(boolean expectDelayedInit)
* @param url The {@link String} URL base URL that the Branch API uses.
*/
public static void setAPIUrl(String url) {
PrefHelper.setAPIUrl(url);
BranchLogger.v("setAPIUrl: Branch API URL was set to " + url);
if (!TextUtils.isEmpty(url)) {
if (!url.endsWith("/")) {
url = url + "/";

Check warning on line 512 in Branch-SDK/src/main/java/io/branch/referral/Branch.java

View check run for this annotation

Codecov / codecov/patch

Branch-SDK/src/main/java/io/branch/referral/Branch.java#L512

Added line #L512 was not covered by tests
}

PrefHelper.setAPIUrl(url);
BranchLogger.v("setAPIUrl: Branch API URL was set to " + url);

Check warning on line 516 in Branch-SDK/src/main/java/io/branch/referral/Branch.java

View check run for this annotation

Codecov / codecov/patch

Branch-SDK/src/main/java/io/branch/referral/Branch.java#L515-L516

Added lines #L515 - L516 were not covered by tests
} else {
BranchLogger.w("setAPIUrl: URL cannot be empty or null");

Check warning on line 518 in Branch-SDK/src/main/java/io/branch/referral/Branch.java

View check run for this annotation

Codecov / codecov/patch

Branch-SDK/src/main/java/io/branch/referral/Branch.java#L518

Added line #L518 was not covered by tests
}
}
/**
* <p>Sets a custom CDN base URL.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static void setAPIBaseUrlFromConfig(Context context) {
BranchJsonConfig jsonConfig = BranchJsonConfig.getInstance(context);
String apiUrl = jsonConfig.getAPIUrl();
if (!TextUtils.isEmpty(apiUrl)) {
Branch.setAPIUrl(apiUrl + "/");
Branch.setAPIUrl(apiUrl);

Check warning on line 147 in Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java

View check run for this annotation

Codecov / codecov/patch

Branch-SDK/src/main/java/io/branch/referral/BranchUtil.java#L147

Added line #L147 was not covered by tests
}
}

Expand Down

0 comments on commit 127db77

Please sign in to comment.