mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-29 14:04:19 +03:00
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
100d9ede35
commit
a68ccaf59a
5
.changes/tauri-asset-protocol.md
Normal file
5
.changes/tauri-asset-protocol.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'tauri': 'patch:bug'
|
||||
---
|
||||
|
||||
Fix `asset` protocol failing to fetch files.
|
@ -1355,8 +1355,8 @@ impl<R: Runtime> Builder<R> {
|
||||
/// ```
|
||||
/// tauri::Builder::default()
|
||||
/// .register_uri_scheme_protocol("app-files", |_app, request| {
|
||||
/// let path = request.uri().path().trim_start_matches('/');
|
||||
/// if let Ok(data) = std::fs::read(path) {
|
||||
/// // skip leading `/`
|
||||
/// if let Ok(data) = std::fs::read(&request.uri().path()[1..]) {
|
||||
/// http::Response::builder()
|
||||
/// .body(data)
|
||||
/// .unwrap()
|
||||
@ -1397,7 +1397,8 @@ impl<R: Runtime> Builder<R> {
|
||||
/// ```
|
||||
/// tauri::Builder::default()
|
||||
/// .register_asynchronous_uri_scheme_protocol("app-files", |_app, request, responder| {
|
||||
/// let path = request.uri().path().trim_start_matches('/').to_string();
|
||||
/// // skip leading `/`
|
||||
/// let path = request.uri().path()[1..].to_string();
|
||||
/// std::thread::spawn(move || {
|
||||
/// if let Ok(data) = std::fs::read(path) {
|
||||
/// responder.respond(
|
||||
|
@ -291,8 +291,8 @@ fn parse_invoke_request<R: Runtime>(
|
||||
#[allow(unused_mut)]
|
||||
let (parts, mut body) = request.into_parts();
|
||||
|
||||
let cmd = parts.uri.path().trim_start_matches('/');
|
||||
let cmd = percent_encoding::percent_decode(cmd.as_bytes())
|
||||
// skip leading `/`
|
||||
let cmd = percent_encoding::percent_decode(parts.uri.path()[1..].as_bytes())
|
||||
.decode_utf8_lossy()
|
||||
.to_string();
|
||||
|
||||
|
@ -34,7 +34,8 @@ fn get_response(
|
||||
scope: &FsScope,
|
||||
window_origin: &str,
|
||||
) -> Result<Response<Cow<'static, [u8]>>, Box<dyn std::error::Error>> {
|
||||
let path = percent_encoding::percent_decode(request.uri().path().as_bytes())
|
||||
// skip leading `/`
|
||||
let path = percent_encoding::percent_decode(request.uri().path()[1..].as_bytes())
|
||||
.decode_utf8_lossy()
|
||||
.to_string();
|
||||
|
||||
|
4
examples/api/src-tauri/Cargo.lock
generated
4
examples/api/src-tauri/Cargo.lock
generated
@ -3399,7 +3399,7 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
|
||||
|
||||
[[package]]
|
||||
name = "tauri"
|
||||
version = "2.0.0-alpha.13"
|
||||
version = "2.0.0-alpha.14"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -3568,7 +3568,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime-wry"
|
||||
version = "1.0.0-alpha.1"
|
||||
version = "1.0.0-alpha.2"
|
||||
dependencies = [
|
||||
"cocoa 0.24.1",
|
||||
"gtk",
|
||||
|
@ -78,9 +78,8 @@ fn get_stream_response(
|
||||
request: http::Request<Vec<u8>>,
|
||||
boundary_id: &Arc<Mutex<i32>>,
|
||||
) -> Result<http::Response<Vec<u8>>, Box<dyn std::error::Error>> {
|
||||
// get the file path
|
||||
let path = request.uri().path();
|
||||
let path = percent_encoding::percent_decode(path.as_bytes())
|
||||
// skip leading `/`
|
||||
let path = percent_encoding::percent_decode(request.uri().path()[1..].as_bytes())
|
||||
.decode_utf8_lossy()
|
||||
.to_string();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user