Skip to content

Commit 97544c6

Browse files
committed
.
1 parent 2c7c6c0 commit 97544c6

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/utils.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -890,15 +890,10 @@ pub async fn parse_post(post: &Value) -> Post {
890890

891891
/// Grab a query parameter from a url
892892
pub fn param(path: &str, value: &str) -> Option<String> {
893-
Some(
894-
Url::parse(format!("https://libredd.it/{path}").as_str())
895-
.ok()?
896-
.query_pairs()
897-
.into_owned()
898-
.collect::<HashMap<_, _>>()
899-
.get(value)?
900-
.clone(),
901-
)
893+
let query = path.splitn(2, '?').nth(1).unwrap_or_default();
894+
url::form_urlencoded::parse(query.as_bytes())
895+
.find(|(k, _)| k == value)
896+
.map(|(_, v)| v.into_owned())
902897
}
903898

904899
/// Retrieve the value of a setting by name

0 commit comments

Comments
 (0)