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,12 +330,20 @@ fn handle_connection(
let mut audio_path = path.clone(); let mut audio_path = path.clone();
let path = percent_decode_str(relative_path).decode_utf8_lossy(); let path = percent_decode_str(relative_path).decode_utf8_lossy();
if let Some((path, mut file)) = path.rsplit_once('/') {
println!("{path} -> {file}");
if path.contains('_') { if path.contains('_') {
let path = path.replace('_', " "); 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, "HTTP/1.1 308 Permanent Redirect\r\n");
let _ = write!(stream, "Location: /{path}\r\n\r\n"); let _ = write!(stream, "Location: /{path}/{file}\r\n\r\n");
return; return;
} }
}
pk_path.push(format!("{path}.pk")); pk_path.push(format!("{path}.pk"));
mld_path.push(format!("{path}.mld")); mld_path.push(format!("{path}.mld"));