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 <mail@tazj.in>
This commit is contained in:
Vincent Ambo 2021-05-05 12:08:14 +02:00 committed by tazjin
parent 55c4b8d4c0
commit 67389b6b0b

View file

@ -63,7 +63,12 @@ fn main() {
rouille::start_server(&address, move |request| { rouille::start_server(&address, move |request| {
rouille::log(&request, std::io::stderr(), || { 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(), None => fallback(),
Some(destination) => Response::redirect_303(destination), Some(destination) => Response::redirect_303(destination),
} }
@ -93,7 +98,10 @@ mod tests {
Some("https://cl.tvl.fyi/42".to_string()) 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,); assert_eq!(dispatch(&queries(), "cl/invalid"), None,);
} }
} }