From 04072c41bccf6af42d91b0041f9ec13dd9978443 Mon Sep 17 00:00:00 2001 From: Gwendal Date: Sat, 18 Aug 2018 12:55:23 +0200 Subject: [PATCH] Make cookie parsing nullcheck consistent with nullable types --- .../BandcampCollectionDownloader.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt b/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt index 5f06568..b9e26fe 100644 --- a/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt +++ b/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt @@ -17,10 +17,10 @@ import javax.mail.internet.ContentDisposition data class ParsedCookie( @SerializedName("Name raw") - val nameRaw: String, + val nameRaw: String?, @SerializedName("Content raw") - val contentRaw: String + val contentRaw: String? ) data class ParsedBandcampData( @@ -43,13 +43,13 @@ data class ParsedStatDownload( fun parsedCookiesToMap(parsedCookies: Array): Map { val result = HashMap() for (parsedCookie in parsedCookies) { - if (parsedCookie.contentRaw == null) { + if (parsedCookie.contentRaw.isNullOrEmpty()) { throw BandCampDownloaderError("Missing 'Content raw' field in cookie number ${parsedCookies.indexOf(parsedCookie) + 1}.") } - if (parsedCookie.nameRaw == null) { + if (parsedCookie.nameRaw.isNullOrEmpty()) { throw BandCampDownloaderError("Missing 'Name raw' field in cookie number ${parsedCookies.indexOf(parsedCookie) + 1}.") } - result.put(parsedCookie.nameRaw, parsedCookie.contentRaw) + result.put(parsedCookie.nameRaw!!, parsedCookie.contentRaw!!) } return result }