Skip to content

Commit 2003a02

Browse files
committed
finish 0.31
fix bug where null har content text would cause HarCleaner exception
1 parent aaae64c commit 2003a02

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/com/github/mike10004/seleniumhelp/HarCleaner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public List<HarEntry> clean(Har inputHar) {
4848
String contentEncoding = getHeaderValue(rsp.getHeaders(), HttpHeaders.CONTENT_ENCODING);
4949
if (HEADER_VALUE_BROTLI_ENCODED.equalsIgnoreCase(contentEncoding) && content != null) {
5050
String text = content.getText();
51-
if (base64Alphabet().matchesAllOf(text)) {
51+
if (text != null && base64Alphabet().matchesAllOf(text)) {
5252
return true;
5353
}
5454
}

src/test/java/com/github/mike10004/seleniumhelp/HarCleanerTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.common.io.CharSource;
55
import com.google.common.io.Resources;
66
import com.google.common.net.HttpHeaders;
7+
import com.google.common.net.MediaType;
78
import net.lightbody.bmp.core.har.*;
89
import org.junit.Test;
910

@@ -95,4 +96,17 @@ private HarResponse buildResponse(String contentTypeHeader, String contentEncodi
9596
response.getHeaders().addAll(headers);
9697
return response;
9798
}
99+
100+
@Test
101+
public void clean_entryResponseContentTextNull() throws Exception {
102+
Har har = new Har();
103+
HarResponse response = buildResponse(MediaType.JAVASCRIPT_UTF_8.toString(), "br", (String)null, "base64");
104+
HarEntry entry = new HarEntry();
105+
entry.setResponse(response);
106+
HarLog log = new HarLog();
107+
log.addEntry(entry);
108+
har.setLog(log);
109+
new HarCleaner().clean(har);
110+
assertEquals("num entries after clean", 1, har.getLog().getEntries().size());
111+
}
98112
}

0 commit comments

Comments
 (0)