Skip to content

Commit 357480f

Browse files
authored
feat(core): custom protocol headers on Linux, closes #4496 (#5421)
1 parent 95f467a commit 357480f

File tree

9 files changed

+164
-179
lines changed

9 files changed

+164
-179
lines changed

Diff for: .changes/custom-protocol-uri-parse.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": minor
3+
---
4+
5+
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.

Diff for: .changes/linux-header-support.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": minor
3+
"tauri-runtime-wry": minor
4+
---
5+
6+
Custom protocol headers are now implemented on Linux when running on webkit2gtk 2.36 or above.

Diff for: core/tauri-runtime-wry/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ webview2-com = "0.19.1"
2929

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

3535
[target."cfg(any(target_os = \"ios\", target_os = \"macos\"))".dependencies]

Diff for: core/tauri/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ notify-rust = { version = "4.5", default-features = false, features = [ "d" ], o
9393
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
9494
gtk = { version = "0.15", features = [ "v3_20" ] }
9595
glib = "0.15"
96-
webkit2gtk = { version = "0.18", features = [ "v2_22" ] }
96+
webkit2gtk = { version = "0.18.2", features = [ "v2_36" ] }
9797

9898
[target."cfg(target_os = \"macos\")".dependencies]
9999
embed_plist = "1.2"

Diff for: core/tauri/scripts/bundle.global.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: core/tauri/src/manager.rs

-4
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,11 @@ impl<R: Runtime> WindowManager<R> {
513513
pending.register_uri_scheme_protocol("asset", move |request| {
514514
let parsed_path = Url::parse(request.uri())?;
515515
let filtered_path = &parsed_path[..Position::AfterPath];
516-
#[cfg(target_os = "windows")]
517516
let path = filtered_path
518517
.strip_prefix("asset://localhost/")
519518
// the `strip_prefix` only returns None when a request is made to `https://tauri.$P` on Windows
520519
// where `$P` is not `localhost/*`
521520
.unwrap_or("");
522-
// safe to unwrap: request.uri() always starts with this prefix
523-
#[cfg(not(target_os = "windows"))]
524-
let path = filtered_path.strip_prefix("asset://").unwrap();
525521
let path = percent_encoding::percent_decode(path.as_bytes())
526522
.decode_utf8_lossy()
527523
.to_string();

Diff for: examples/api/dist/assets/index.js

+41-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)