From 8ac2812d05ae993ea5c9013877ab4c6a1906454a Mon Sep 17 00:00:00 2001 From: Stepan Kuzmin Date: Thu, 18 Oct 2018 20:05:33 +0300 Subject: [PATCH] fix: function source query params parse --- src/utils.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index a6cf2ec7..94671cc3 100755 --- a/src/utils.rs +++ b/src/utils.rs @@ -16,12 +16,13 @@ pub fn build_tilejson( ) -> Result { let source_id = source.get_id(); - let path = headers - .get("x-rewrite-url") - .map_or(Ok(path.trim_right_matches(".json")), |header| { - let header_str = header.to_str()?; - Ok(header_str.trim_right_matches(".json")) - })?; + let path = + headers + .get("x-rewrite-url") + .map_or(Ok(path.trim_right_matches(".json")), |header| { + let header_str = header.to_str()?; + Ok(header_str.trim_right_matches(".json")) + })?; let query = if query_string.is_empty() { query_string.to_owned() @@ -99,7 +100,9 @@ pub fn json_to_hashmap(value: &serde_json::Value) -> HashMap { pub fn query_to_json_string(query: &Query) -> Result { let mut query_as_json = HashMap::new(); for (k, v) in query.iter() { - let json_value: serde_json::Value = serde_json::from_str(v)?; + let json_value: serde_json::Value = + serde_json::from_str(v).unwrap_or_else(|_| serde_json::Value::String(v.clone())); + query_as_json.insert(k, json_value); }