about summary refs log tree commit diff
path: root/web/atward/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-05-05T10·08+0200
committertazjin <mail@tazj.in>2021-05-06T10·23+0000
commit67389b6b0b70a5eab821b6c7c9eb23072858f960 (patch)
treeee024ceaeac7851ea09ab2a3aed08785b746d170 /web/atward/src
parent55c4b8d4c0b7a4ef5d9cffc15926d1faeea55414 (diff)
fix(atward): Use 'q' query parameter for query instead r/2569
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 <mail@tazj.in>
Diffstat (limited to 'web/atward/src')
-rw-r--r--web/atward/src/main.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/web/atward/src/main.rs b/web/atward/src/main.rs
index e412def4a969..aef41a29b4e7 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,);
     }
 }