Support headers with spaces in their value
This commit is contained in:
parent
625fd24113
commit
6383d98772
1 changed files with 17 additions and 1 deletions
|
@ -161,7 +161,7 @@ fn parse_tricot_tag(
|
|||
}
|
||||
|
||||
fn parse_tricot_add_header_tag(tag: &str) -> Option<(String, String)> {
|
||||
let splits = tag.split(' ').collect::<Vec<_>>();
|
||||
let splits = tag.splitn(3, ' ').collect::<Vec<_>>();
|
||||
if splits.len() == 3 && splits[0] == "tricot-add-header" {
|
||||
Some((splits[1].to_string(), splits[2].to_string()))
|
||||
} else {
|
||||
|
@ -352,3 +352,19 @@ pub fn spawn_proxy_config_task(
|
|||
|
||||
rx
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_parse_tricot_add_header_tag() {
|
||||
match parse_tricot_add_header_tag("tricot-add-header Content-Security-Policy default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'") {
|
||||
Some((name, value)) => {
|
||||
assert_eq!(name, "Content-Security-Policy");
|
||||
assert_eq!(value, "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'");
|
||||
}
|
||||
_ => panic!("Passed a valid tag but the function says it is not valid")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue