diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbde2f0..5dee835 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.3
+## Fixed
+* URL concatenation on the different versions of the JDK and upstream projects' dependencies
+
# 0.4.2
## Fixed
* GRANT_TYPE_TOKEN_REFRESH now has the correct value
diff --git a/pom.xml b/pom.xml
index ad4df3c..0a4a129 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@ and https://issues.apache.org/jira/browse/SUREFIRE-1588 -->
com.patreon
patreon
- 0.4.2
+ 0.4.3
${project.groupId}:${project.artifactId}
Interact with the Patreon API via OAuth
diff --git a/src/main/java/com/patreon/resources/RequestUtil.java b/src/main/java/com/patreon/resources/RequestUtil.java
index cabb20e..9ed0820 100644
--- a/src/main/java/com/patreon/resources/RequestUtil.java
+++ b/src/main/java/com/patreon/resources/RequestUtil.java
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
import java.net.URL;
import static com.patreon.PatreonAPI.BASE_URI;
@@ -13,8 +14,7 @@
public class RequestUtil {
public InputStream request(String pathSuffix, String accessToken) throws IOException {
- String prefix = BASE_URI + "/api/oauth2/api/";
- URL url = new URL(prefix.concat(pathSuffix));
+ URL url = buildUrl(pathSuffix);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", "Bearer ".concat(accessToken));
connection.setRequestProperty("User-Agent",
@@ -26,6 +26,16 @@ public InputStream request(String pathSuffix, String accessToken) throws IOExcep
return connection.getInputStream();
}
+ private URL buildUrl(String pathSuffix) throws MalformedURLException {
+ if (pathSuffix.startsWith("/")) {
+ pathSuffix = pathSuffix.substring(1, pathSuffix.length());
+ }
+
+ String prefix = BASE_URI + "/api/oauth2/api/";
+ URL url = new URL(prefix.concat(pathSuffix));
+ return url;
+ }
+
private String getVersion() throws IOException {
InputStream resourceAsStream = this.getClass().getResourceAsStream("/version.properties");
java.util.Properties prop = new java.util.Properties();