Fix SpaceSafeURI nullability issues

This commit is contained in:
comp500
2022-02-21 22:03:56 +00:00
parent 46771ce870
commit bca2d758e1
3 changed files with 9 additions and 10 deletions

View File

@@ -78,9 +78,9 @@ class IndexFile {
get() {
if (metafile) {
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

View File

@@ -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", " ")
@@ -52,9 +52,9 @@ class SpaceSafeURI : Comparable<SpaceSafeURI>, Serializable {
override fun compareTo(other: SpaceSafeURI): Int = u.compareTo(other.u)
val scheme: String get() = u.scheme
val authority: String get() = u.authority
val host: String get() = u.host
val scheme: String? get() = u.scheme
val authority: String? get() = u.authority
val host: String? get() = u.host
@Throws(MalformedURLException::class)
fun toURL(): URL = u.toURL()