Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/main/java/org/archive/url/URLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,20 @@ public static HandyURL parse(String urlString) throws URISyntaxException {
colonPort = uriAuthority.substring(portColonIndex);
}
if(colonPort != null) {
if(colonPort.startsWith(":")) {
try {
port = Integer.parseInt(colonPort.substring(1));
} catch(NumberFormatException e) {
throw new URISyntaxException(urlString, "bad port "
+ colonPort.substring(1));
}
} else {
// XXX: what's happened?!
}
if(colonPort.startsWith(":")) {
if (colonPort.length() == 1) {
// a bare colon (http://example.com:/), use default port
} else {
try {
port = Integer.parseInt(colonPort.substring(1));
} catch(NumberFormatException e) {
throw new URISyntaxException(urlString, "bad port "
+ colonPort.substring(1));
}
}
} else {
// XXX: what's happened?!
}
}
if(userInfo != null) {
int passColonIndex = userInfo.indexOf(COLON);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/archive/url/IAURLCanonicalizerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void testFull() throws URISyntaxException {
compCan(iaC,"https://www.archive.org:80/","https://archive.org:80/");
compCan(iaC,"http://www.archive.org:443/","http://archive.org:443/");
compCan(iaC,"https://www.archive.org:443/","https://archive.org/");
compCan(iaC,"http://www.archive.org:/","http://archive.org/");
compCan(iaC,"http://www.archive.org/big/","http://archive.org/big");
compCan(iaC,"dns:www.archive.org","dns:www.archive.org");

Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/archive/url/WaybackURLKeyMakerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void testMakeKey() throws URISyntaxException {
assertEquals("org,archive)/goo", km.makeKey("http://archive.org/goo/?"));
assertEquals("org,archive)/goo?a&b", km.makeKey("http://archive.org/goo/?b&a"));
assertEquals("org,archive)/goo?a=1&a=2&b", km.makeKey("http://archive.org/goo/?a=2&b&a=1"));
assertEquals("org,archive)/", km.makeKey("http://archive.org:/"));
}

}