Skip to content

Commit

Permalink
Fixed encode_to_url_string_and_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
amigin committed Mar 27, 2024
1 parent 55002ff commit bf9e5f0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/url_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn decode_from_url_string(src: &str) -> String {
if escape_pos == 0 {
escape0 = c as u8;
escape_pos += 1;
} else if escape_pos == 0 {
} else if escape_pos == 1 {
escape_pos += 1;
let c = decode_url_escape(escape0, c as u8);
result.push(c);
Expand Down Expand Up @@ -178,3 +178,19 @@ lazy_static! {
.copied()
.collect();
}

#[cfg(test)]
mod tests {

#[test]
fn test_from_real_life() {
let src = "4%2F0AeaYSHA_pv6LYFSy9QdDASiSdr4X53iOaoo9ZJotKi536ELdyaLNqbsaQ0sjsTE9yuhhdQ";

let result = super::decode_from_url_string(src);

assert_eq!(
result,
"4/0AeaYSHA_pv6LYFSy9QdDASiSdr4X53iOaoo9ZJotKi536ELdyaLNqbsaQ0sjsTE9yuhhdQ"
);
}
}

0 comments on commit bf9e5f0

Please sign in to comment.