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

Fixed Zimit archives are not displaying correctly. #3580

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ class ZimFileReader constructor(
}

private fun toRedirect(url: String) =
"$CONTENT_PREFIX${getActualUrl(url, true)}".toUri()
"$CONTENT_PREFIX${getActualUrl(url)}".toUri()

private fun getActualUrl(url: String, actualUrl: Boolean = false): String {
private fun getActualUrl(url: String): String {
val actualPath = url.toUri().filePath.decodeUrl
var redirectPath = try {
jniKiwixReader.getEntryByPath(actualPath)
Expand All @@ -220,7 +220,7 @@ class ZimFileReader constructor(
} catch (ignore: Exception) {
actualPath.replaceWithEncodedString
}
if (actualUrl && url.decodeUrl.contains("?")) {
if (url.decodeUrl.contains("?")) {
redirectPath += extractQueryParam(url)
}
return redirectPath
Expand Down Expand Up @@ -294,7 +294,9 @@ class ZimFileReader constructor(

private fun getItem(url: String): Item? =
try {
jniKiwixReader.getEntryByPath(getActualUrl(url)).getItem(true)
val actualPath = url.toUri().filePath.decodeUrl
jniKiwixReader.getEntryByPath(actualPath)
.getItem(true)
} catch (exception: Exception) {
Log.e(TAG, "Could not get Item for url = $url \n original exception = $exception")
null
Expand Down