From 2d39f12060c3624174eff6ec0dc84156dc73ae1c Mon Sep 17 00:00:00 2001 From: Christian Schulze Date: Sat, 1 Jan 2022 05:36:50 +1100 Subject: [PATCH] fix: #3137 - remove querystring when using asset protocol (#3141) Co-authored-by: Lucas Nogueira --- core/tauri/src/manager.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/tauri/src/manager.rs b/core/tauri/src/manager.rs index f3b519117..37a636bad 100644 --- a/core/tauri/src/manager.rs +++ b/core/tauri/src/manager.rs @@ -43,7 +43,7 @@ use std::{ }; use tauri_macros::default_runtime; use tokio::io::{AsyncReadExt, AsyncSeekExt}; -use url::Url; +use url::{Position, Url}; const WINDOW_RESIZED_EVENT: &str = "tauri://resize"; const WINDOW_MOVED_EVENT: &str = "tauri://move"; @@ -320,10 +320,12 @@ impl WindowManager { ) }; pending.register_uri_scheme_protocol("asset", move |request| { + let parsed_path = Url::parse(&request.uri())?; + let filtered_path = &parsed_path[..Position::AfterPath]; #[cfg(target_os = "windows")] - let path = request.uri().replace("asset://localhost/", ""); + let path = filtered_path.replace("asset://localhost/", ""); #[cfg(not(target_os = "windows"))] - let path = request.uri().replace("asset://", ""); + let path = filtered_path.replace("asset://", ""); let path = percent_encoding::percent_decode(path.as_bytes()) .decode_utf8_lossy() .to_string(); @@ -499,7 +501,7 @@ impl WindowManager { let path = request .uri() .split(&['?', '#'][..]) - // ignore query string + // ignore query string and fragment .next() .unwrap() .to_string()