Skip to content

Commit 7be63d5

Browse files
committed
Fix/Improve JAR download detection
1 parent d2fbc5a commit 7be63d5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
projectVersion=2.2.2
1+
projectVersion=2.2.3
22

33
mcVersions=1.21,1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9,1.8.8,1.8.7,1.8.6,1.8.5,1.8.4,1.8.3,1.8.2,1.8.1,1.8
44
mcVersionRange=1.8-1.21

plugin/src/main/kotlin/gg/flyte/pluginportal/plugin/util/File.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ fun isJarDownloadUrl(url: String): Boolean {
1313
if (url.endsWith(".jar")) return true
1414

1515
val connection = runCatching { URL(url).openConnection() as HttpURLConnection }.getOrNull() ?: return false
16-
val fileName = connection.getHeaderField("x-bz-file-name") ?: return false
17-
if (fileName.endsWith(".jar")) return true
16+
17+
connection.getHeaderField("x-bz-file-name")?.let {
18+
return it.endsWith(".jar")
19+
}
1820

1921
connection.instanceFollowRedirects = false
20-
val contentDisposition = connection.getHeaderField("Content-Disposition")
21-
return contentDisposition?.let {
22-
it.contains("attachment") && it.contains("filename=") && it.contains(".jar")
23-
} ?: false
22+
connection.getHeaderField("Content-Disposition")?.let {
23+
return it.contains("attachment") && it.contains("filename=") && it.contains(".jar")
24+
}
25+
26+
return false
2427
}
2528

2629
fun File.isJarFile() = isFile && extension == "jar"

0 commit comments

Comments
 (0)