From 5eeee8069c794e7798ecb3b756cf0a81dc944510 Mon Sep 17 00:00:00 2001 From: Timo Furrer Date: Tue, 8 Oct 2024 16:11:50 +0200 Subject: [PATCH] fix: properly trim volume content before stripping percentage sign (#18) --- src/play.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/play.rs b/src/play.rs index 0e7d507..044c3fc 100644 --- a/src/play.rs +++ b/src/play.rs @@ -44,7 +44,8 @@ impl InitialProperties { // Basically just read from the volume file if it exists, otherwise return 100. let volume = if volume.exists() { let contents = fs::read_to_string(volume).await?; - let stripped = contents.trim().strip_suffix("%").unwrap_or(&contents); + let trimmed = contents.trim(); + let stripped = trimmed.strip_suffix("%").unwrap_or(&trimmed); stripped .parse() .map_err(|_| eyre!("volume.txt file is invalid"))?