From ad5678584a555bd7b323b9df0b77f97581e57798 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 13 Nov 2018 20:23:23 +0100 Subject: license: Get URL path without query string parameters The `REQUEST_URI` parameter gives us the URL path including the query string. Unfortunately, there's no param for just the path without the query string. Well, that's not entirely true. On my production server I'll be using Apache, and in development I'm using Lighttpd. Apache provides a `SCRIPT_URL` param that does include just the path, but Lighttpd doesn't appear to have an equivalent. I wasn't able to figure out how to add a `SCRIPT_URL` param in Lighttpd manually, either. Using `bin-environment` in the FastCGI config didn't work, and using `setenv.add-environment` wouldn't allow me to set it to both of our routes (I assume). In light of this, just grab the path from `REQUEST_URI` by getting the part in front of `?`. --- license-generator/src/bin/license.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/license-generator/src/bin/license.rs b/license-generator/src/bin/license.rs index ca29260..5010fff 100644 --- a/license-generator/src/bin/license.rs +++ b/license-generator/src/bin/license.rs @@ -215,6 +215,8 @@ fn main() -> Result<()> { }; if let Some(path) = req.param("REQUEST_URI") { + let path = path.split("?").collect::>()[0]; + match path.as_ref() { "/license" => { // Get params name, email, secret -- cgit v1.2.3