mirror of
https://github.com/house-of-vanity/v2-uri-parser.git
synced 2025-12-15 22:47:52 +00:00
29 lines
780 B
Rust
29 lines
780 B
Rust
pub mod inbound_generator;
|
|
|
|
pub fn url_decode_str(value: &str) -> Option<String> {
|
|
urlencoding::decode(value)
|
|
.ok()
|
|
.map(|decoded| decoded.into_owned())
|
|
}
|
|
|
|
pub fn url_decode(value: Option<String>) -> Option<String> {
|
|
value.and_then(|s| {
|
|
urlencoding::decode(&s)
|
|
.ok()
|
|
.map(|decoded| decoded.into_owned())
|
|
})
|
|
}
|
|
|
|
pub fn parse_raw_json(input: &str) -> Option<serde_json::Value> {
|
|
serde_json::from_str::<serde_json::Value>(input)
|
|
.ok()
|
|
.and_then(|v| match v {
|
|
serde_json::Value::Object(_) => Some(v),
|
|
_ => None,
|
|
})
|
|
}
|
|
|
|
pub fn get_parameter_value(query: &Vec<(&str, &str)>, param: &str) -> Option<String> {
|
|
query.iter().find(|q| q.0 == param).map(|q| q.1.to_string())
|
|
}
|