aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/proxy_config.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs
index e380885..bf7ae32 100644
--- a/src/proxy_config.rs
+++ b/src/proxy_config.rs
@@ -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")
+ }
+ }
+}