*) Bugfix for url concatenation. Relative urls with / or http:// at the beginning

were not handled correctly on url concatenation via new URL(URL,relPath).
   See: http://www.yacy-forum.de/viewtopic.php?t=2623

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2297 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent b5ec7de936
commit 8a1f1d96b3

@ -38,6 +38,10 @@ public class URL {
private int port;
public URL(String url) throws MalformedURLException {
parseURLString(url);
}
public void parseURLString(String url) throws MalformedURLException {
// identify protocol
int p = url.indexOf("://");
if (p < 0) throw new MalformedURLException("protocol is not given in '" + url + "'");
@ -77,17 +81,20 @@ public class URL {
public URL(URL baseURL, String relPath) throws MalformedURLException {
if (baseURL == null) throw new MalformedURLException("base URL is null");
if (relPath.startsWith("/")) relPath = relPath.substring(1);
if (relPath.toLowerCase().startsWith("http://")) parseURLString(relPath);
else {
this.protocol = baseURL.protocol;
this.host = baseURL.host;
this.port = baseURL.port;
this.path = (baseURL.path.endsWith("/")) ? (baseURL.path + relPath) : (baseURL.path + "/" + relPath);
if (relPath.startsWith("/")) this.path = relPath;
else this.path = (baseURL.path.endsWith("/")) ? (baseURL.path + relPath) : (baseURL.path + "/" + relPath);
this.quest = baseURL.quest;
this.ref = baseURL.ref;
identRef();
identQuest();
}
}
public URL(String protocol, String host, int port, String path) throws MalformedURLException {
if (protocol == null) throw new MalformedURLException("protocol is null");

Loading…
Cancel
Save