From 231d3f1c8ced8c98163434e90267f0b99ee5bf41 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 19 Sep 2024 13:15:24 +0200 Subject: [PATCH] Improve URL composition to reduce warnings in log --- src/main/java/org/jivesoftware/site/DiscourseAPI.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jivesoftware/site/DiscourseAPI.java b/src/main/java/org/jivesoftware/site/DiscourseAPI.java index abd8323f..b0f36404 100644 --- a/src/main/java/org/jivesoftware/site/DiscourseAPI.java +++ b/src/main/java/org/jivesoftware/site/DiscourseAPI.java @@ -34,6 +34,9 @@ public void init(ServletConfig servletConfig) throws ServletException { baseUrl = "https://discourse.igniterealtime.org/"; } + if (!baseUrl.endsWith("/")) { + baseUrl = baseUrl + "/"; + } apiKey = servletConfig.getServletContext().getInitParameter("discourse-api-key"); @@ -76,7 +79,7 @@ private static Long doSimpleQuery(final int queryId, final int lastNumberOfDays) parameters.put("download", "true"); try { - return restClient.post(baseUrl + "/admin/plugins/explorer/queries/"+queryId+"/run", headers, parameters).getJSONArray("rows").getJSONArray(0).getLong(0); + return restClient.post(baseUrl + "admin/plugins/explorer/queries/"+queryId+"/run", headers, parameters).getJSONArray("rows").getJSONArray(0).getLong(0); } catch (Throwable t) { Log.warn("Unable to interact with Discourse's API.", t); return null;