diff --git a/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt b/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt index 70d09743..b445c246 100644 --- a/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt +++ b/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt @@ -8,6 +8,7 @@ import java.security.cert.X509Certificate import java.util.concurrent.TimeUnit.MILLISECONDS import javax.net.ssl.SSLContext import javax.net.ssl.X509TrustManager +import okhttp3.Credentials import okhttp3.OkHttpClient import okhttp3.ResponseBody import okhttp3.logging.HttpLoggingInterceptor @@ -73,7 +74,19 @@ class SubsonicAPIClient( .addQueryParameter("c", config.clientID) .addQueryParameter("f", "json") .build() - chain.proceed(originalRequest.newBuilder().url(newUrl).build()) + val newRequestBuilder = originalRequest.newBuilder().url(newUrl) + if (originalRequest.url.username.isNotEmpty() && + originalRequest.url.password.isNotEmpty() + ) { + newRequestBuilder.addHeader( + "Authorization", + Credentials.basic( + originalRequest.url.username, + originalRequest.url.password + ) + ) + } + chain.proceed(newRequestBuilder.build()) } .addInterceptor(versionInterceptor) .addInterceptor(proxyPasswordInterceptor) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt index 84de4a97..6b778c5b 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt @@ -298,7 +298,6 @@ class EditServerFragment : Fragment(), OnBackPressedHandler { url = URL(urlString) if ( urlString != urlString.trim(' ') || - urlString.contains("@") || url.host.isNullOrBlank() ) { throw MalformedURLException()