Skip to content
Snippets Groups Projects
Commit b23f13fc authored by codecraft's avatar codecraft :crocodile:
Browse files

FIX: Uri::new() raw string not being encoded

FIX: Test to  string
parent 377b68cf
No related branches found
No related tags found
1 merge request!2Project Completed
......@@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"
[features]
defautl = []
secure = []
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -2,7 +2,11 @@ use std::str::FromStr;
use crate::{
setup::MountPoint,
utils::{url_utils::datatypes::RawUriElement, urlencoded::UrlEncodeData, vec_utils::remove_n},
utils::{
url_utils::datatypes::RawUriElement,
urlencoded::{EnCodable, UrlEncodeData},
vec_utils::remove_n,
},
};
use super::datatypes::{ParseUriError, RawUri, Uri};
......@@ -21,7 +25,12 @@ impl MountPoint {
impl Uri {
pub fn new(parts: Vec<&str>) -> Self {
Self {
raw: "/".to_owned() + &parts.join("/"),
raw: "/".to_owned()
+ &parts
.iter()
.map(|part| part.encode())
.collect::<Vec<String>>()
.join("/"),
parts: parts.into_iter().map(UrlEncodeData::from_raw).collect(),
}
}
......@@ -214,7 +223,7 @@ mod test {
#[test]
fn uri_to_string() {
assert_eq!("/a/%20", Uri::new(vec!["a", " "]).to_string());
assert_eq!("a/%20", Uri::new(vec!["a", " "]).to_string());
}
#[test]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment