mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-19 21:16:30 +02:00
Fix SpaceSafeURI nullability issues
This commit is contained in:
parent
46771ce870
commit
bca2d758e1
@ -78,9 +78,9 @@ class IndexFile {
|
|||||||
get() {
|
get() {
|
||||||
if (metafile) {
|
if (metafile) {
|
||||||
return linkedFile?.name ?: linkedFile?.filename ?:
|
return linkedFile?.name ?: linkedFile?.filename ?:
|
||||||
file?.run { Paths.get(path).fileName.toString() } ?: "Invalid file"
|
file?.run { Paths.get(path ?: return "Invalid file").fileName.toString() } ?: "Invalid file"
|
||||||
}
|
}
|
||||||
return file?.run { Paths.get(path).fileName.toString() } ?: "Invalid file"
|
return file?.run { Paths.get(path ?: return "Invalid file").fileName.toString() } ?: "Invalid file"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: URIs are bad
|
// TODO: URIs are bad
|
||||||
|
@ -32,7 +32,7 @@ class SpaceSafeURI : Comparable<SpaceSafeURI>, Serializable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val path: String get() = u.path.replace("%20", " ")
|
val path: String? get() = u.path?.replace("%20", " ")
|
||||||
|
|
||||||
override fun toString(): String = u.toString().replace("%20", " ")
|
override fun toString(): String = u.toString().replace("%20", " ")
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ class SpaceSafeURI : Comparable<SpaceSafeURI>, Serializable {
|
|||||||
|
|
||||||
override fun compareTo(other: SpaceSafeURI): Int = u.compareTo(other.u)
|
override fun compareTo(other: SpaceSafeURI): Int = u.compareTo(other.u)
|
||||||
|
|
||||||
val scheme: String get() = u.scheme
|
val scheme: String? get() = u.scheme
|
||||||
val authority: String get() = u.authority
|
val authority: String? get() = u.authority
|
||||||
val host: String get() = u.host
|
val host: String? get() = u.host
|
||||||
|
|
||||||
@Throws(MalformedURLException::class)
|
@Throws(MalformedURLException::class)
|
||||||
fun toURL(): URL = u.toURL()
|
fun toURL(): URL = u.toURL()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package link.infra.packwiz.installer.request.handlers
|
package link.infra.packwiz.installer.request.handlers
|
||||||
|
|
||||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import kotlin.concurrent.read
|
import kotlin.concurrent.read
|
||||||
@ -21,7 +20,7 @@ class RequestHandlerGithub : RequestHandlerZip(true) {
|
|||||||
private val zipUriMap: MutableMap<String, SpaceSafeURI> = HashMap()
|
private val zipUriMap: MutableMap<String, SpaceSafeURI> = HashMap()
|
||||||
private val zipUriLock = ReentrantReadWriteLock()
|
private val zipUriLock = ReentrantReadWriteLock()
|
||||||
private fun getRepoName(loc: SpaceSafeURI): String? {
|
private fun getRepoName(loc: SpaceSafeURI): String? {
|
||||||
val matcher = repoMatcherPattern.matcher(loc.path)
|
val matcher = repoMatcherPattern.matcher(loc.path ?: return null)
|
||||||
return if (matcher.matches()) {
|
return if (matcher.matches()) {
|
||||||
matcher.group(1)
|
matcher.group(1)
|
||||||
} else {
|
} else {
|
||||||
@ -47,7 +46,7 @@ class RequestHandlerGithub : RequestHandlerZip(true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getBranch(loc: SpaceSafeURI): String? {
|
private fun getBranch(loc: SpaceSafeURI): String? {
|
||||||
val matcher = branchMatcherPattern.matcher(loc.path)
|
val matcher = branchMatcherPattern.matcher(loc.path ?: return null)
|
||||||
return if (matcher.matches()) {
|
return if (matcher.matches()) {
|
||||||
matcher.group(1)
|
matcher.group(1)
|
||||||
} else {
|
} else {
|
||||||
@ -66,6 +65,6 @@ class RequestHandlerGithub : RequestHandlerZip(true) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// TODO: more match testing?
|
// TODO: more match testing?
|
||||||
return "github.com" == loc.host && branchMatcherPattern.matcher(loc.path).matches()
|
return "github.com" == loc.host && branchMatcherPattern.matcher(loc.path ?: return false).matches()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user