Skip to content

Commit

Permalink
Merge pull request #4287 from owncloud/fix/compose_app_list_path_wron…
Browse files Browse the repository at this point in the history
…g_when_instance_in_subfolder

[BUG] 4.1.1 composes /app/list path wrong when instance is installed in subfolder (/owncloud)
  • Loading branch information
Aitorbp authored Jan 24, 2024
2 parents c6b2fed + 522d9bb commit a5c8863
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ownCloud admins and users.
* Bugfix - Bugs related to Details view: [#4188](https://github.com/owncloud/android/issues/4188)
* Bugfix - Some Null Pointer Exceptions fixed from Google Play: [#4207](https://github.com/owncloud/android/issues/4207)
* Bugfix - Add "scope" parameter to /token endpoint HTTP requests: [#4260](https://github.com/owncloud/android/pull/4260)
* Bugfix - Fix in the handling of the base URL: [#4279](https://github.com/owncloud/android/issues/4279)
* Change - Android library as a module instead of submodule: [#3962](https://github.com/owncloud/android/issues/3962)
* Enhancement - Koin DSL: [#3966](https://github.com/owncloud/android/pull/3966)
* Enhancement - Unit tests for datasources classes - Part 1 & Fixes: [#4063](https://github.com/owncloud/android/issues/4063)
Expand Down Expand Up @@ -103,6 +104,14 @@ ownCloud admins and users.

https://github.com/owncloud/android/pull/4260

* Bugfix - Fix in the handling of the base URL: [#4279](https://github.com/owncloud/android/issues/4279)

Base URL has been formatted in GetRemoteAppRegistryOperation when server
instance is installed in subfolder, so that the endpoint is formed correctly.

https://github.com/owncloud/android/issues/4279
https://github.com/owncloud/android/pull/4287

* Change - Android library as a module instead of submodule: [#3962](https://github.com/owncloud/android/issues/3962)

Android library, containing all networking stuff, is now the 5th module in the
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/4287
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix in the handling of the base URL

Base URL has been formatted in GetRemoteAppRegistryOperation
when server instance is installed in subfolder, so that the endpoint is formed correctly.

https://github.com/owncloud/android/issues/4279
https://github.com/owncloud/android/pull/4287
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperati
var result: RemoteOperationResult<AppRegistryResponse>

try {
val uriBuilder = client.baseUri.buildUpon().apply {
appendEncodedPath(appUrl)
}
val getMethod = GetMethod(URL(uriBuilder.build().toString()))
val urlFormatted = removeSubfolder(client.baseUri.toString()) + appUrl
val getMethod = GetMethod(URL(urlFormatted))

val status = client.executeHttpMethod(getMethod)

val response = getMethod.getResponseBodyAsString()
Expand Down Expand Up @@ -75,4 +74,15 @@ class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperati

return result
}

private fun removeSubfolder(url: String): String {
val doubleSlashIndex = url.indexOf("//")
val nextSlashIndex = url.indexOf('/', doubleSlashIndex + 2)
return if (nextSlashIndex >= 0) {
val result = url.substring(0, nextSlashIndex)
if (result.endsWith("/")) result else "$result/"
} else {
if (url.endsWith("/")) url else "$url/"
}
}
}

0 comments on commit a5c8863

Please sign in to comment.