feat: handle subset of urlendcoded

This commit is contained in:
Compositr 2024-11-02 18:04:07 +11:00
parent d7421324dc
commit 5f2109787f

View file

@ -26,7 +26,14 @@ impl URL {
Some(key) => key.to_string(), Some(key) => key.to_string(),
None => continue, None => continue,
}; };
let value = key_value.next().unwrap_or("").to_string(); let value = key_value
.next()
.unwrap_or("")
.to_string()
.replace("+", " ")
.replace("%20", " ")
.replace("%23", "#")
.replace("%2C", ",");
query.insert(key, value); query.insert(key, value);
} }
@ -41,13 +48,13 @@ impl URL {
} }
/// Utility function to get a path segment by index /// Utility function to get a path segment by index
/// ///
/// This is a very simple function, and its implementation is fairly naïve /// This is a very simple function, and its implementation is fairly naïve
/// ///
/// index: Index of the path segment to get /// index: Index of the path segment to get
/// ///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// let url = URL::new("/path/to/resource").unwrap(); /// let url = URL::new("/path/to/resource").unwrap();
/// assert_eq!(url.get_path_segment(1), Some("to")); /// assert_eq!(url.get_path_segment(1), Some("to"));
@ -94,7 +101,11 @@ impl Request {
None => return RequestStatus::MalformedHTTP(stream), None => return RequestStatus::MalformedHTTP(stream),
}; };
RequestStatus::Ok(Request { stream, method, url }) RequestStatus::Ok(Request {
stream,
method,
url,
})
} }
pub fn mut_stream(self) -> TcpStream { pub fn mut_stream(self) -> TcpStream {