Skip to content

Commit

Permalink
Fix test for properly encoded redirect records
Browse files Browse the repository at this point in the history
  • Loading branch information
ato committed Aug 6, 2024
1 parent 05c5f0c commit 27e634a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/au/gov/nla/httrack2warc/Httrack2WarcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public void test() throws IOException {
StringBuilder summary = new StringBuilder();
try (WarcReader warcReader = new WarcReader(outdir.resolve("crawl-0.warc.gz"))) {
for (WarcRecord warcRecord: warcReader) {
URI url = warcRecord instanceof WarcTargetRecord ? ((WarcTargetRecord) warcRecord).targetURI() : null;
String url = warcRecord instanceof WarcTargetRecord ? ((WarcTargetRecord) warcRecord).target() : null;
summary.append(warcRecord.type()).append(" ").append(url).append("\n");

// HTTrack generates bad http requests containing a fragment which jwarc strictly rejects, just skip them
if (url != null && url.getFragment() != null) continue;
if (url != null && URI.create(url).getFragment() != null) continue;

if (warcRecord instanceof WarcRequest) {
assertEquals(MessageVersion.HTTP_1_1, ((WarcRequest) warcRecord).http().version());
Expand Down Expand Up @@ -87,9 +87,9 @@ public void test() throws IOException {
"request http://test.example.org/redirect\n" +
"metadata http://test.example.org/redirect\n" +
"response http://prefix.example.org/test.example.org/redirect\n" +
"response http://test.example.org/page%2520WITH%2520%2522special%2522%2520chars.html\n" +
"request http://test.example.org/page%2520WITH%2520%2522special%2522%2520chars.html\n" +
"metadata http://test.example.org/page%2520WITH%2520%2522special%2522%2520chars.html\n" +
"response http://test.example.org/page%20WITH%20%22special%22%20chars.html\n" +
"request http://test.example.org/page%20WITH%20%22special%22%20chars.html\n" +
"metadata http://test.example.org/page%20WITH%20%22special%22%20chars.html\n" +
"response http://prefix.example.org/test.example.org/page%20WITH%20_special_%20chars.html\n" +
"response http://test.example.org/image.gif\n" +
"request http://test.example.org/image.gif\n" +
Expand Down

0 comments on commit 27e634a

Please sign in to comment.