Skip to content

Commit

Permalink
fix: slightly improve sanitize_display_format logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hozarho committed Nov 18, 2024
1 parent 2404192 commit 1af3d0e
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions jellyfin-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,12 @@ impl Client {
}

fn sanitize_display_format(input: &str) -> String {
let mut result = input.to_string();

result = result.trim().to_string();

// Remove unnecessary spaces
while result.contains(" ") {
result = result.replace(" ", " ");
}
let mut result = input.trim().split_whitespace().collect::<Vec<&str>>().join(" ");

// Remove duplicated separators
while result.contains("{sep}{sep}") {
while result.contains("{sep}{sep}") || result.contains("{sep} {sep}") {
result = result.replace("{sep}{sep}", "{sep}");
}
while result.contains("{sep} {sep}") {
result = result.replace("{sep} {sep}", "{sep}");
}

Expand Down

0 comments on commit 1af3d0e

Please sign in to comment.