diff --git a/cropper/app/lib/CropSpecMetadata.scala b/cropper/app/lib/CropSpecMetadata.scala index 4baa9cd3fc..f6875a5816 100644 --- a/cropper/app/lib/CropSpecMetadata.scala +++ b/cropper/app/lib/CropSpecMetadata.scala @@ -17,9 +17,14 @@ trait CropSpecMetadata { "date" -> crop.date.map(printDateTime), "width" -> dimensions.width, "height" -> dimensions.height, - ) ++ r.map("aspect-ratio" -> _) + "aspect-ratio" -> r) - val flattenedMetadata = metadata.collect { + val nonEmptyMetadata = metadata.filter { + case (_, None) => false + case _ => true + } + + val flattenedMetadata = nonEmptyMetadata.collect { case (key, Some(value)) => key -> value case (key, value) => key -> value }.view.mapValues(_.toString).toMap diff --git a/cropper/test/lib/CropSpecMetadataTest.scala b/cropper/test/lib/CropSpecMetadataTest.scala index 421bc31441..bfd3c8c8d1 100644 --- a/cropper/test/lib/CropSpecMetadataTest.scala +++ b/cropper/test/lib/CropSpecMetadataTest.scala @@ -37,7 +37,7 @@ class CropSpecMetadataTest extends AnyFunSpec with Matchers with CropSpecMetadat val metadata = metadataForCrop(crop.copy(specification = withEmptyField, author = None), dimensions) metadata.get("aspect-ratio") shouldBe None - metadata.get("author") shouldBe Some("None") // TODO this does not look intentional! + metadata.get("author") shouldBe None } it("should round trip metadata back to crop spec") {