From 112a7913d4b4f700fc066b85c7aa65be4221336c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 20 Aug 2020 17:57:48 +0200 Subject: [PATCH] Improve (unused) code --- .../session/permalinks/DefaultPermalinkService.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt index 04736303fe..cef1fce05c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt @@ -43,10 +43,9 @@ internal class DefaultPermalinkService @Inject constructor( } override fun getLinkedId(url: String): String? { - val isSupported = url.startsWith(MATRIX_TO_URL_BASE) - - return if (isSupported) { - url.substring(MATRIX_TO_URL_BASE.length) - } else null + return url + .takeIf { it.startsWith(MATRIX_TO_URL_BASE) } + ?.substring(MATRIX_TO_URL_BASE.length) + ?.substringBeforeLast("?") } }