Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 23f4142

Browse files
committed
Encoding whitespaces in download urls
Closes #70 Signed-off-by: DeathsGun <deathsgun@protonmail.com>
1 parent 56f2fa4 commit 23f4142

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/kotlin/xyz/deathsgun/modmanager/update/UpdateManager.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class UpdateManager {
254254
version.assets.find { (it.filename.endsWith(".jar") || it.primary) && !it.filename.contains("forge") }
255255
?: return ModUpdateResult.Error(TranslatableText("modmanager.error.update.noFabricJar"))
256256
val jar = dir.resolve(asset.filename) // Download into same directory where the old jar was
257-
val request = HttpRequest.newBuilder(URI.create(asset.url)).GET()
257+
val request = HttpRequest.newBuilder(URI.create(encodeURI(asset.url))).GET()
258258
.setHeader("User-Agent", "ModManager ${ModManager.getVersion()}").build()
259259
val response = this.http.send(request, HttpResponse.BodyHandlers.ofFile(jar))
260260
if (response.statusCode() != 200) {
@@ -277,6 +277,7 @@ class UpdateManager {
277277
ModManager.modManager.changed = true
278278
ModUpdateResult.Success
279279
} catch (e: Exception) {
280+
e.printStackTrace()
280281
ModUpdateResult.Error(TranslatableText("modmanager.error.unknown.update", e))
281282
}
282283
}
@@ -405,4 +406,9 @@ class UpdateManager {
405406
return ModRemoveResult.Error(TranslatableText("modmanager.error.jar.failedDelete", e))
406407
}
407408
}
409+
410+
private fun encodeURI(url: String): String {
411+
return URI("dummy", url, null).rawSchemeSpecificPart
412+
}
413+
408414
}

0 commit comments

Comments
 (0)