1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
pub fn unsafe_unescape<S: Into<String>>(base64_url: S) -> String {
let mut result = base64_url.into().into_bytes();
for n in result.iter_mut() {
match *n {
45 => *n = 43,
95 => *n = 47,
_ => ()
}
}
let padding = result.len() % 4;
if padding > 0 {
for _ in padding..4 {
result.push(61);
}
}
unsafe {
String::from_utf8_unchecked(result)
}
}
#[deprecated(since = "1.1.7", note = "please use `unsafe_escape` instead")]
pub fn unsafe_unescape_owned(base64_url: String) -> String {
unsafe_unescape(base64_url)
}