diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-30 18:07:51 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-30 18:08:20 +0100 |
commit | e0f1e44dfeb3514dec15ebac07e145963322d5ca (patch) | |
tree | 593b8cfbf4d454ff704267ec87fb8f847749fd0b | |
parent | Frontend: Implement support for searching with /search/* routes (diff) | |
download | OSSE-e0f1e44dfeb3514dec15ebac07e145963322d5ca.tar.gz OSSE-e0f1e44dfeb3514dec15ebac07e145963322d5ca.tar.bz2 OSSE-e0f1e44dfeb3514dec15ebac07e145963322d5ca.zip |
Frontend: URL encode and decode the search_query
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | frontend/Cargo.toml | 1 | ||||
-rw-r--r-- | frontend/src/app.rs | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock index 7264d47..54f74db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -620,6 +620,7 @@ dependencies = [ "gloo-net", "itertools", "lib", + "urlencoding", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -2546,6 +2547,12 @@ dependencies = [ ] [[package]] +name = "urlencoding" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" + +[[package]] name = "utf-8" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index 3730022..f3d1e6d 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -15,4 +15,5 @@ wasm-bindgen = "0.2.83" gloo-net = "0.2" wasm-bindgen-futures = "0.4" itertools = "0.10.5" +urlencoding = "2.1.2" lib = { path = "../lib" } \ No newline at end of file diff --git a/frontend/src/app.rs b/frontend/src/app.rs index 78c42dd..b84d814 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -68,7 +68,7 @@ impl Component for OSSE { } OSSE { - search_query, + search_query: urlencoding::decode(search_query.as_str()).to_owned().unwrap().to_string(), results: None, } } @@ -80,7 +80,7 @@ impl Component for OSSE { let search_query = self.search_query.clone(); let navigator = ctx.link().navigator().unwrap(); - navigator.push(&Route::OSSESearch { query: search_query.clone() }); + navigator.push(&Route::OSSESearch { query: urlencoding::encode(search_query.as_str()).to_string() }); ctx.link().send_future(async move { let endpoint = format!("{}/search/{}", api_endpoint, search_query); |