Skip to content

Commit

Permalink
feat(core): custom protocol headers on Linux, closes #4496 (#5421)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Oct 17, 2022
1 parent 95f467a commit 357480f
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 179 deletions.
5 changes: 5 additions & 0 deletions .changes/custom-protocol-uri-parse.md
@@ -0,0 +1,5 @@
---
"tauri": minor
---

The custom protocol now validates the request URI. This has implications when using the `asset` protocol without the `convertFileSrc` helper, the URL must now use the `asset://localhost/$filePath` format.
6 changes: 6 additions & 0 deletions .changes/linux-header-support.md
@@ -0,0 +1,6 @@
---
"tauri": minor
"tauri-runtime-wry": minor
---

Custom protocol headers are now implemented on Linux when running on webkit2gtk 2.36 or above.
2 changes: 1 addition & 1 deletion core/tauri-runtime-wry/Cargo.toml
Expand Up @@ -29,7 +29,7 @@ webview2-com = "0.19.1"

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.15", features = [ "v3_20" ] }
webkit2gtk = { version = "0.18", features = [ "v2_22" ] }
webkit2gtk = { version = "0.18.2", features = [ "v2_36" ] }
percent-encoding = "2.1"

[target."cfg(any(target_os = \"ios\", target_os = \"macos\"))".dependencies]
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/Cargo.toml
Expand Up @@ -93,7 +93,7 @@ notify-rust = { version = "4.5", default-features = false, features = [ "d" ], o
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.15", features = [ "v3_20" ] }
glib = "0.15"
webkit2gtk = { version = "0.18", features = [ "v2_22" ] }
webkit2gtk = { version = "0.18.2", features = [ "v2_36" ] }

[target."cfg(target_os = \"macos\")".dependencies]
embed_plist = "1.2"
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/scripts/bundle.global.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions core/tauri/src/manager.rs
Expand Up @@ -513,15 +513,11 @@ impl<R: Runtime> WindowManager<R> {
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 = filtered_path
.strip_prefix("asset://localhost/")
// the `strip_prefix` only returns None when a request is made to `https://tauri.$P` on Windows
// where `$P` is not `localhost/*`
.unwrap_or("");
// safe to unwrap: request.uri() always starts with this prefix
#[cfg(not(target_os = "windows"))]
let path = filtered_path.strip_prefix("asset://").unwrap();
let path = percent_encoding::percent_decode(path.as_bytes())
.decode_utf8_lossy()
.to_string();
Expand Down
81 changes: 41 additions & 40 deletions examples/api/dist/assets/index.js

Large diffs are not rendered by default.

0 comments on commit 357480f

Please sign in to comment.