From 9c0d2ed7d7758c85106d65a171f306bba7d5c64a Mon Sep 17 00:00:00 2001 From: Paulo Bressan Date: Sat, 16 Nov 2024 16:25:10 -0300 Subject: [PATCH] fix: fixed proxy api key (#76) --- proxy/src/proxy.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/proxy/src/proxy.rs b/proxy/src/proxy.rs index 772eb80..d165029 100644 --- a/proxy/src/proxy.rs +++ b/proxy/src/proxy.rs @@ -116,15 +116,12 @@ impl ProxyHttp for KupoProxy { .get_header("host") .map(|v| v.to_str().unwrap()) .unwrap(); - let captures = self.host_regex.captures(host).unwrap(); - let mut key = session + let key = session .get_header(DMTR_API_KEY) - .map(|v| v.to_str().unwrap()) + .and_then(|v| v.to_str().ok()) + .or_else(|| captures.get(1).map(|v| v.as_str())) .unwrap_or_default(); - if let Some(m) = captures.get(1) { - key = m.as_str(); - } let consumer = state.get_consumer(key).await; if consumer.is_none() {