@@ -503,9 +503,13 @@ impl<R: Runtime> WindowManager<R> {
503503 pending. register_uri_scheme_protocol ( "asset" , move |request| {
504504 let parsed_path = Url :: parse ( request. uri ( ) ) ?;
505505 let filtered_path = & parsed_path[ ..Position :: AfterPath ] ;
506- // safe to unwrap: request.uri() always starts with this prefix
507506 #[ cfg( target_os = "windows" ) ]
508- let path = filtered_path. strip_prefix ( "asset://localhost/" ) . unwrap ( ) ;
507+ let path = filtered_path
508+ . strip_prefix ( "asset://localhost/" )
509+ // the `strip_prefix` only returns None when a request is made to `https://tauri.$P` on Windows
510+ // where `$P` is not `localhost/*`
511+ . unwrap_or ( "" ) ;
512+ // safe to unwrap: request.uri() always starts with this prefix
509513 #[ cfg( not( target_os = "windows" ) ) ]
510514 let path = filtered_path. strip_prefix ( "asset://" ) . unwrap ( ) ;
511515 let path = percent_encoding:: percent_decode ( path. as_bytes ( ) )
@@ -830,10 +834,11 @@ impl<R: Runtime> WindowManager<R> {
830834 // ignore query string and fragment
831835 . next ( )
832836 . unwrap ( )
833- // safe to unwrap: request.uri() always starts with this prefix
834837 . strip_prefix ( "tauri://localhost" )
835- . unwrap ( )
836- . to_string ( ) ;
838+ . map ( |p| p. to_string ( ) )
839+ // the `strip_prefix` only returns None when a request is made to `https://tauri.$P` on Windows
840+ // where `$P` is not `localhost/*`
841+ . unwrap_or_else ( || "" . to_string ( ) ) ;
837842 let asset = manager. get_asset ( path) ?;
838843 let mut builder = HttpResponseBuilder :: new ( )
839844 . header ( "Access-Control-Allow-Origin" , & window_origin)
0 commit comments