miko-core 0.3.9

Core for miko
Documentation
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC, utf8_percent_encode};

const SAFE_CHARS: &AsciiSet = &NON_ALPHANUMERIC
    .remove(b'/')
    .remove(b'-')
    .remove(b'_')
    .remove(b':')
    .remove(b'.')
    .remove(b'{')
    .remove(b'}');

pub fn encode_route(path: &str) -> String {
    utf8_percent_encode(path, SAFE_CHARS).to_string()
}

pub fn decode_path(path: &str) -> String {
    percent_encoding::percent_decode_str(path)
        .decode_utf8_lossy()
        .trim_start_matches('/')
        .to_string()
}