Skip to content

Commit

Permalink
Simplify cookie extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
bitterpanda63 committed Feb 28, 2025
1 parent 89657ec commit 1ff11e9
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import dev.aikido.agent_api.helpers.logging.Logger;

import java.lang.reflect.Executable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -73,15 +74,11 @@ public static Object interceptOnEnter(
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
List<String> newValue;
// If the cookie is already inside the map, add the value to the existing list
if (cookiesMap.containsKey(cookie.getName())) {
newValue = cookiesMap.get(cookie.getName());
newValue.add(cookie.getValue());
} else {
newValue = List.of(cookie.getValue());
// If no entry exists, create a new empty entry
if (!cookiesMap.containsKey(cookie.getName())) {
cookiesMap.put(cookie.getName(), new ArrayList<>());
}
cookiesMap.put(cookie.getName(), newValue);
cookiesMap.get(cookie.getName()).add(cookie.getValue());
}
}

Expand Down

0 comments on commit 1ff11e9

Please sign in to comment.