miko-core 0.1.6

Core for miko
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};

const SAFE_CHARS: &AsciiSet = &NON_ALPHANUMERIC
    .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()
}