From b23f13fcdbc0d06007d14dc3a2c656492a201c17 Mon Sep 17 00:00:00 2001
From: Darius Auding <Darius.auding@gmx.de>
Date: Sun, 23 Jul 2023 21:11:24 +0200
Subject: [PATCH] FIX: Uri::new() raw string not being encoded FIX: Test to 
 string

---
 core/http/Cargo.toml                 |  1 +
 core/http/src/utils/url_utils/uri.rs | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml
index 5d24dbd..4d7fb4f 100644
--- a/core/http/Cargo.toml
+++ b/core/http/Cargo.toml
@@ -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
diff --git a/core/http/src/utils/url_utils/uri.rs b/core/http/src/utils/url_utils/uri.rs
index 3a726a3..0a36f30 100644
--- a/core/http/src/utils/url_utils/uri.rs
+++ b/core/http/src/utils/url_utils/uri.rs
@@ -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]
-- 
GitLab