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

add a workaround for double url encoded + in the resources path #107

Merged
merged 3 commits into from
Dec 8, 2024
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 @@ -27,7 +27,20 @@ object ResourceFilePath:
val srcUriStr = head.toURI().toString()
val jarFilePath = srcUriStr.slice(srcUriStr.lastIndexOf(":") + 1, srcUriStr.lastIndexOf("!"))

val resources = scala.util.Using.resource(java.util.zip.ZipFile(jarFilePath)) { fs =>
val resources = scala.util.Using.resource {
try {
java.util.zip.ZipFile(jarFilePath)
} catch {
case _: Throwable =>
// another attempt as a (hopefully temporary) workaround in case a path got URL encoded twice
// e.g. a common SNAPSHOT version may contain a '+' sign and look like 'my-lib-0.0.0+123-456-SNAPSHOT'
// it seems to end up URL encoded on the file system (at least via coursier) and look like that "my-lib-0.0.0%2B123-456-SNAPSHOT.jar"
// on getting the URL via getResources() the path is URL encoded again and becomes: "my-lib-0.0.0%252B123-456-SNAPSHOT.jar"
// not sure yet which side would need to fix that, for now this gets it working
// helps only with a double encoded `+` sign which may be commonly used in snapshot versions
java.util.zip.ZipFile(jarFilePath.replace("%252B", "%2B"))
}
} { fs =>
fs
.entries()
.asScala
Expand Down
Loading