From 9257169bf35a8c1bc3ad55a9385f5502ada8adc4 Mon Sep 17 00:00:00 2001 From: Krunal Patel Date: Sun, 27 Nov 2022 19:23:45 +0530 Subject: [PATCH] Fix download issue caused by file name --- app/src/main/java/com/github/libretube/extensions/Sanitize.kt | 2 +- .../main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/extensions/Sanitize.kt b/app/src/main/java/com/github/libretube/extensions/Sanitize.kt index 75f5ac0da..7c7e9cad4 100644 --- a/app/src/main/java/com/github/libretube/extensions/Sanitize.kt +++ b/app/src/main/java/com/github/libretube/extensions/Sanitize.kt @@ -4,5 +4,5 @@ package com.github.libretube.extensions * Replace file name specific chars */ fun String.sanitize(): String { - return this.replace("[^a-zA-Z0-9\\._]+", "_") + return this.replace("[^a-zA-Z0-9\\\\._]+".toRegex(), "_") } diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt index f721cbb3f..6169c1c81 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt @@ -124,7 +124,7 @@ class DownloadDialog( if (binding.audioSpinner.size >= 1) binding.audioSpinner.setSelection(1) binding.download.setOnClickListener { - if (binding.fileName.text.toString().length < 1) { + if (binding.fileName.text.toString().isEmpty()) { Toast.makeText(context, R.string.invalid_filename, Toast.LENGTH_SHORT).show() return@setOnClickListener }