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" ...@@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[features] [features]
defautl = []
secure = [] secure = []
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
...@@ -2,7 +2,11 @@ use std::str::FromStr; ...@@ -2,7 +2,11 @@ use std::str::FromStr;
use crate::{ use crate::{
setup::MountPoint, 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}; use super::datatypes::{ParseUriError, RawUri, Uri};
...@@ -21,7 +25,12 @@ impl MountPoint { ...@@ -21,7 +25,12 @@ impl MountPoint {
impl Uri { impl Uri {
pub fn new(parts: Vec<&str>) -> Self { pub fn new(parts: Vec<&str>) -> Self {
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(), parts: parts.into_iter().map(UrlEncodeData::from_raw).collect(),
} }
} }
...@@ -214,7 +223,7 @@ mod test { ...@@ -214,7 +223,7 @@ mod test {
#[test] #[test]
fn uri_to_string() { 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] #[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