Skip to content

Commit

Permalink
Fix app name finding in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
cosad3s committed Jul 24, 2024
1 parent 29a9b07 commit 6fa8618
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/cosades/salsa/client/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ public void login(final SalesforceAuraCredentialsPojo credentials) throws Salesf
// Find app name (maybe not useful)
List<Header> appNameHeader = HttpUtils.findHeaders(responseAuraToken, "link");
if (!appNameHeader.isEmpty()) {
String regex = ".*%40markup%3A%2F%2F([a-zA-Z0-9:%]*)%22%3A%22.*";
String regex = "%40markup%3A%2F%2F([a-zA-Z0-9:%])*?%22%3A%22";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(appNameHeader.get(0).getValue());
boolean find = m.find();
if (find) {
this.auraAppName = HttpUtils.urlDecode(m.group(1));
String fullString = m.group(0); // ex: %40markup%3A%2F%2Fsiteforce%3AcommunityApp%22%3A%22
this.auraAppName = HttpUtils.urlDecode(fullString.replace("%40markup%3A%2F%2F", "").replace("%22%3A%22",""));
logger.info("[*] Found the app name: {}", this.auraAppName);
} else {
logger.warn("[!] Cannot find the Salesforce Aura app name. Will continue with a default one [{}]", this.auraAppName);
Expand Down

0 comments on commit 6fa8618

Please sign in to comment.