Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 4.1.1 composes /app/list path wrong when instance is installed in subfolder (/owncloud) #4287

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("//")
JuancaG05 marked this conversation as resolved.
Show resolved Hide resolved
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/"
}
}
}