From 480d69f1e13aee2a81537858db670b0f46d3f6af Mon Sep 17 00:00:00 2001 From: Paulo Ribeiro Date: Mon, 18 Jan 2021 12:18:45 +0000 Subject: [PATCH] fix: Improve robustness when building Codacy API base URL By using the java.net.URL constructor we ensure that the version path "/2.0" is always appended after the authority component of the URL. --- src/main/scala/com/codacy/api/client/CodacyClient.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/codacy/api/client/CodacyClient.scala b/src/main/scala/com/codacy/api/client/CodacyClient.scala index 4c3fd14..d9e4170 100644 --- a/src/main/scala/com/codacy/api/client/CodacyClient.scala +++ b/src/main/scala/com/codacy/api/client/CodacyClient.scala @@ -3,6 +3,7 @@ package com.codacy.api.client import play.api.libs.json._ import com.codacy.api.util.JsonOps import scalaj.http.Http +import java.net.URL import scala.util.{Failure, Success, Try} import scala.util.control.NonFatal @@ -25,7 +26,7 @@ class CodacyClient( apiToken.map(t => "api_token" -> t) ++ projectToken.map(t => "project_token" -> t) - private val remoteUrl = apiUrl.getOrElse("https://api.codacy.com") + "/2.0" + private val remoteUrl = new URL(new URL(apiUrl.getOrElse("https://api.codacy.com")), "/2.0").toString() /* * Does an API request and parses the json output into a class