Skip to content

Commit

Permalink
Update AuraDiscriptor.bambda
Browse files Browse the repository at this point in the history
  • Loading branch information
0xasa authored Jul 10, 2024
1 parent 60493fc commit d654295
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions CustomColumn/Proxy/HTTP/SalesForce/AuraDiscriptor.bambda
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
/**
/**
* Extracts the specific part of the action descriptor from Salesforce Aura requests
* and formats it to display the keyword before :// and the last word after /
* e.g., "serviceComponent: ACTION$getItems"
* @author Aussan Saad-Ali
**/

// Check if the request path contains 'aura'
if (requestResponse.finalRequest().path().contains("aura")) {
// Extract the body of the request
if (requestResponse.finalRequest().path().contains("aura")) {
var requestBody = requestResponse.finalRequest().bodyToString().trim();

// Regex to find the URL-encoded 'message' parameter in the body
var messageParamPattern = java.util.regex.Pattern.compile("message=([^&]+)");
var messageMatcher = messageParamPattern.matcher(requestBody);

if (messageMatcher.find()) {
// Decode the message parameter
var decodedMessage = java.net.URLDecoder.decode(messageMatcher.group(1), "UTF-8").trim();

// Regex to parse any 'descriptor' from the decoded message
var descriptorPattern = java.util.regex.Pattern.compile("\"descriptor\":\"([^\" ]+)");
var descriptorPattern = java.util.regex.Pattern.compile("\"descriptor\":\"([^\"]+)");
var descriptorMatcher = descriptorPattern.matcher(decodedMessage);

if (descriptorMatcher.find()) {
return "/" + descriptorMatcher.group(1);
var fullDescriptor = descriptorMatcher.group(1);
// Extract the keyword before :// and the last word after /
var keywordBefore = fullDescriptor.substring(0, fullDescriptor.indexOf("://"));
var lastWordAfter = fullDescriptor.substring(fullDescriptor.lastIndexOf("/") + 1);
return keywordBefore + ": " + lastWordAfter;
}
}
}

return ""; // Return empty if no relevant action is found
return "";

0 comments on commit d654295

Please sign in to comment.