Merge pull request #9426 from nextcloud/fix/unified-search-apps

UnifiedSearch: Fix opening non-file results with relative URLs
This commit is contained in:
Álvaro Brey 2021-12-09 15:59:31 +01:00 committed by GitHub
commit 0edba984be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,8 +147,19 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic
if (result.isFile) {
openFile(result.remotePath())
} else {
val uri = Uri.parse(result.resourceUrl)
this.browserUri.value = uri
this.browserUri.value = getResultUri(result)
}
}
private fun getResultUri(result: SearchResultEntry): Uri {
val uri = Uri.parse(result.resourceUrl)
return when (uri.host) {
null -> {
val serverUrl = currentAccountProvider.user.server.uri.toString()
val fullUrl = serverUrl + result.resourceUrl
Uri.parse(fullUrl)
}
else -> uri
}
}