diff --git a/src/main/kotlin/controller/api/AudioApiController.kt b/src/main/kotlin/controller/api/AudioApiController.kt index 6530669..0e55b35 100644 --- a/src/main/kotlin/controller/api/AudioApiController.kt +++ b/src/main/kotlin/controller/api/AudioApiController.kt @@ -20,6 +20,13 @@ ) { companion object { private const val PAGE_LIMIT = 50 + private fun splitKeywords(keywords: String?): List? { + return if (keywords?.isNotEmpty() == true) { + keywords?.split("\\s".toRegex())?.toList() + } else { + null + } + } } @GetMapping @@ -31,10 +38,10 @@ ): ResponseEntity = ResponseEntity.ok( audioService.getByKeywords( - audioName?.split("\\s".toRegex())?.toList(), - artistName?.split("\\s".toRegex())?.toList(), - albumName?.split("\\s".toRegex())?.toList(), - tagName?.split("\\s".toRegex())?.toList(), + splitKeywords(audioName), + splitKeywords(artistName), + splitKeywords(albumName), + splitKeywords(tagName), PAGE_LIMIT ) )