velto 1.9.0

Velto: expressive, async-native, and grounded Rust framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::collections::HashMap;
use urlencoding::decode;

/// Parses a URL-encoded form body into a HashMap with percent-decoding.
pub fn parse(body: &str) -> HashMap<String, String> {
    body.split('&')
        .filter_map(|pair| {
            let mut parts = pair.splitn(2, '=');
            let key = decode(parts.next()?.trim()).ok()?.to_string();
            let val = decode(parts.next()?.trim()).ok()?.to_string();
            Some((key, val))
        })
        .collect()
}