[FEATURE] Added ability to append query to URI

This commit is contained in:
JKetelaar
2016-06-05 00:58:20 +02:00
parent 4e8f71a89a
commit 7a22f11923
@@ -5,10 +5,7 @@ import org.parabot.core.io.ProgressListener;
import org.parabot.core.io.SizeInputStream;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.net.*;
/**
*
@@ -308,4 +305,18 @@ public class WebUtil {
}
return jsonParser;
}
public static URI appendUri(String uri, String appendQuery) throws URISyntaxException {
URI oldUri = new URI(uri);
String newQuery = oldUri.getQuery();
if (newQuery == null) {
newQuery = appendQuery;
} else {
newQuery += "&" + appendQuery;
}
return new URI(oldUri.getScheme(), oldUri.getAuthority(),
oldUri.getPath(), newQuery, oldUri.getFragment());
}
}