Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #82 from readium/fixes/relative-path-encoding
Browse files Browse the repository at this point in the history
changed encoding to replacement
  • Loading branch information
aferditamuriqi authored Sep 9, 2019
2 parents 62a8c1f + a93008a commit eb66e7b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import java.io.ByteArrayOutputStream
import java.io.File
import java.io.FileInputStream
import java.net.URI
import java.net.URLEncoder

interface DirectoryContainer : Container {

override fun data(relativePath: String): ByteArray {

val encodedPath = URLEncoder.encode(relativePath, "UTF-8");
val decodedFilePath = rootFile.rootPath + "/" + getDecodedRelativePath(encodedPath)
val decodedFilePath = rootFile.rootPath + "/" + getDecodedRelativePath(relativePath)
val file = File(decodedFilePath)

if (!file.exists())
Expand All @@ -45,7 +43,9 @@ interface DirectoryContainer : Container {
FileInputStream(File(rootFile.toString() + "/" + getDecodedRelativePath(relativePath)))

fun getDecodedRelativePath(relativePath: String): String {
return URI(relativePath).path
// val encodedPath = URLEncoder.encode(relativePath, "UTF-8");
val replacedPath = relativePath.replace(" ", "%20")
return URI(replacedPath).path
}
}

0 comments on commit eb66e7b

Please sign in to comment.