Redirect when using underscores for spaces
This commit is contained in:
parent
24b840be87
commit
d58952a96e
12
src/main.rs
12
src/main.rs
@ -87,10 +87,16 @@ impl Context {
|
||||
let relative_path = if relative_path.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
percent_decode_str(&relative_path[1..])
|
||||
.decode_utf8_lossy()
|
||||
.replace('_', " ")
|
||||
let path = percent_decode_str(&relative_path[1..]).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;
|
||||
}
|
||||
path.to_string()
|
||||
};
|
||||
|
||||
let (pk_file, pki_file, start_level) = if !relative_path.is_empty() {
|
||||
path.push(&relative_path);
|
||||
let (pk_extension, pki_extension) = if let Some(extension) = path.extension() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user