Skip to content

Commit

Permalink
Trim brackets from header values
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonso-salces committed Jan 26, 2024
1 parent 7a20309 commit dfaa556
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/android/FileTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Licensed to the Apache Software Foundation (ASF) under one
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;

Expand Down Expand Up @@ -925,9 +927,15 @@ private JSONObject getFileEntryWithHeaders(Map<String, List<String>> headers, JS
continue;
}

json.put(entry.getKey(), entry.getValue());
json.put(entry.getKey(), trimBrackets(entry.getValue().toString()));
}

return fileEntry.put("headers", json);
}

private String trimBrackets(String header) {
Pattern pattern = Pattern.compile("\\[(.*?)\\]");
Matcher matcher = pattern.matcher(header);
return matcher.find() ? matcher.group(1) : header;
}
}

0 comments on commit dfaa556

Please sign in to comment.