Underscore fix for images

This commit is contained in:
p11 2025-05-29 21:15:30 +02:00
parent 95653cde84
commit c8f2cd8b66

View File

@ -330,11 +330,19 @@ fn handle_connection(
let mut audio_path = path.clone();
let path = percent_decode_str(relative_path).decode_utf8_lossy();
if path.contains('_') {
let path = path.replace('_', " ");
let _ = write!(stream, "HTTP/1.1 308 Permanent Redirect\r\n");
let _ = write!(stream, "Location: /{path}\r\n\r\n");
return;
if let Some((path, mut file)) = path.rsplit_once('/') {
println!("{path} -> {file}");
if path.contains('_') {
let path = path.replace('_', " ");
let replaced_file;
if !file.contains('.') {
replaced_file = file.replace('_', " ");
file = &replaced_file;
}
let _ = write!(stream, "HTTP/1.1 308 Permanent Redirect\r\n");
let _ = write!(stream, "Location: /{path}/{file}\r\n\r\n");
return;
}
}
pk_path.push(format!("{path}.pk"));