fix MultiProtocolURL init (assign of host) for urls with '/' in query part

+ add to test case
pull/65/head
reger 9 years ago
parent 163d0cc3cf
commit f89d4eb51d

@ -216,7 +216,13 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
if (!this.protocol.equals("file") && url.substring(p + 1, p + 3).equals("//")) {
// identify host, userInfo and file for http and ftp protocol
int q = url.indexOf('/', p + 3);
if (q < 0) q = url.indexOf("?", p + 3); // check for www.test.com?searchpart
if (q < 0) { // check for www.test.com?searchpart
q = url.indexOf("?", p + 3);
} else { // check that '/' was not in searchpart (example http://test.com?data=1/2/3)
if (url.lastIndexOf("?",q) >= 0) {
q = url.lastIndexOf("?",q);
}
}
int r;
if (q < 0) {
if ((r = url.indexOf('@', p + 3)) < 0) {

@ -127,6 +127,9 @@ public class MultiProtocolURLTest {
new String[]{"http://www.yacy.net?query=test", "www.yacy.net"},
new String[]{"http://www.yacy.net:?query=test", "www.yacy.net"},
new String[]{"//www.yacy.net:?query=test", "www.yacy.net"},
new String[]{"http://www.yacy.net?data=1/2/3", "www.yacy.net"},
new String[]{"http://www.yacy.net?url=http://test.com", "www.yacy.net"}
};
for (int i = 0; i < testStrings.length; i++) {

Loading…
Cancel
Save