From 67389b6b0b70a5eab821b6c7c9eb23072858f960 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 5 May 2021 12:08:14 +0200 Subject: fix(atward): Use 'q' query parameter for query instead This removes a bunch of awkwardness around slashes in URLs, which also frequently feature in our patterns. Change-Id: I68c69d4c68436421951ee133bfbc067609f27bb6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3097 Tested-by: BuildkiteCI Reviewed-by: tazjin --- web/atward/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/atward/src/main.rs b/web/atward/src/main.rs index e412def4a9..aef41a29b4 100644 --- a/web/atward/src/main.rs +++ b/web/atward/src/main.rs @@ -63,7 +63,12 @@ fn main() { rouille::start_server(&address, move |request| { rouille::log(&request, std::io::stderr(), || { - match dispatch(&queries, &request.url()) { + let query = match request.get_param("q") { + Some(q) => q, + None => return fallback(), + }; + + match dispatch(&queries, &query) { None => fallback(), Some(destination) => Response::redirect_303(destination), } @@ -93,7 +98,10 @@ mod tests { Some("https://cl.tvl.fyi/42".to_string()) ); - assert_eq!(dispatch(&queries(), "something only mentioning cl/42"), None,); + assert_eq!( + dispatch(&queries(), "something only mentioning cl/42"), + None, + ); assert_eq!(dispatch(&queries(), "cl/invalid"), None,); } } -- cgit 1.4.1