|
1 | 1 | package com.easypost.easyvcr; |
2 | 2 |
|
3 | | -import com.easypost.easyvcr.internalutilities.Tools; |
4 | | -import com.easypost.easyvcr.internalutilities.json.Serialization; |
| 3 | +import com.easypost.easyvcr.internal.Utilities; |
| 4 | +import com.easypost.easyvcr.internal.json.Serialization; |
5 | 5 | import com.google.gson.JsonParseException; |
6 | | -import org.apache.http.NameValuePair; |
7 | | -import org.apache.http.client.utils.URLEncodedUtils; |
| 6 | +import com.easypost.easyvcr.internal.ApachePatch; |
8 | 7 |
|
9 | 8 | import java.net.URI; |
10 | 9 | import java.nio.charset.StandardCharsets; |
|
17 | 16 | /** |
18 | 17 | * Censoring capabilities for EasyVCR. |
19 | 18 | */ |
20 | | -@SuppressWarnings("unchecked") |
| 19 | +@SuppressWarnings ("unchecked") |
21 | 20 | public final class Censors { |
22 | 21 | /** |
23 | 22 | * The body elements to censor. |
@@ -113,7 +112,7 @@ private static List<Object> applyJsonCensors(List<Object> list, String censorTex |
113 | 112 | } else if (Utilities.isList(value)) { |
114 | 113 | // recursively censor list elements |
115 | 114 | try { |
116 | | - // change the value if can be parsed as a list |
| 115 | + // change the value if it can be parsed as a list |
117 | 116 | value = applyJsonCensors((List<Object>) value, censorText, elementsToCensor); |
118 | 117 | } catch (ClassCastException e) { |
119 | 118 | // otherwise, skip censoring |
@@ -165,15 +164,15 @@ private static Map<String, Object> applyJsonCensors(Map<String, Object> dictiona |
165 | 164 | if (Utilities.isDictionary(value)) { |
166 | 165 | // recursively censor inner dictionaries |
167 | 166 | try { |
168 | | - // change the value if can be parsed as a dictionary |
| 167 | + // change the value if it can be parsed as a dictionary |
169 | 168 | value = applyJsonCensors((Map<String, Object>) value, censorText, elementsToCensor); |
170 | 169 | } catch (ClassCastException e) { |
171 | 170 | // otherwise, skip censoring |
172 | 171 | } |
173 | 172 | } else if (Utilities.isList(value)) { |
174 | 173 | // recursively censor list elements |
175 | 174 | try { |
176 | | - // change the value if can be parsed as a list |
| 175 | + // change the value if it can be parsed as a list |
177 | 176 | value = applyJsonCensors((List<Object>) value, censorText, elementsToCensor); |
178 | 177 | } catch (ClassCastException e) { |
179 | 178 | // otherwise, skip censoring |
@@ -292,8 +291,7 @@ public static Map<String, List<String>> applyHeaderCensors(Map<String, List<Stri |
292 | 291 | * @param pathElementsToCensor The path elements to censor. |
293 | 292 | * @return Censored URL string. |
294 | 293 | */ |
295 | | - public static String applyUrlCensors(String url, String censorText, |
296 | | - List<CensorElement> queryParamsToCensor, |
| 294 | + public static String applyUrlCensors(String url, String censorText, List<CensorElement> queryParamsToCensor, |
297 | 295 | List<RegexCensorElement> pathElementsToCensor) { |
298 | 296 | if (url == null || url.length() == 0) { |
299 | 297 | // short circuit if url is null |
@@ -342,8 +340,10 @@ public static String applyUrlCensors(String url, String censorText, |
342 | 340 | } |
343 | 341 | } |
344 | 342 |
|
345 | | - List<NameValuePair> censoredQueryParametersList = Tools.mapToQueryParameters(queryParameters); |
346 | | - censoredQueryString = URLEncodedUtils.format(censoredQueryParametersList, StandardCharsets.UTF_8); |
| 343 | + List<ApachePatch.NameValuePair> censoredQueryParametersList = |
| 344 | + Utilities.mapToQueryParameters(queryParameters); |
| 345 | + censoredQueryString = |
| 346 | + ApachePatch.URLEncodedUtils.format(censoredQueryParametersList, StandardCharsets.UTF_8); |
347 | 347 | } |
348 | 348 | } |
349 | 349 |
|
|
0 commit comments