Skip to content

fix(core): AssetResolver.get(): don't skip first char - #12971

Merged
amrbashir merged 1 commit into
tauri-apps:devfrom
WofWca:fix-asset-missing-leading-slash
Mar 14, 2025
Merged

fix(core): AssetResolver.get(): don't skip first char#12971
amrbashir merged 1 commit into
tauri-apps:devfrom
WofWca:fix-asset-missing-leading-slash

Conversation

@WofWca

@WofWca WofWca commented Mar 13, 2025

Copy link
Copy Markdown
Contributor

That is, it would try to get sers/john if you called
AssetResolver.get("users/john").
This commit fixes the bug by only skipping the first character
only if it is a slash (/).

Why it is important:
tauri::WebviewUrl::App() docs state that it's OK to specify
the path as users/john to get tauri://localhost/users/john
in the end.
So if an application developer is using AssetResolver.get()
together with WebviewUrl::App(), they will would get
inconsistent behavior: for the same path, the latter would work,
while the former would fail.
In fact, we encountered this bug in our code,
here.

That is, it would try to get `sers/john` if you called
`AssetResolver.get("users/john")`.
This commit fixes the bug by only skipping the first character
only if it _is_ a slash (/).

Why it is important:
`tauri::WebviewUrl::App()` docs state that it's OK to specify
the path as `users/john` to get `tauri://localhost/users/john`
in the end.
So if an application developer is using `AssetResolver.get()`
together with `WebviewUrl::App()`, they will would get
inconsistent behavior: for the same path, the latter would work,
while the former would fail.
In fact, we encountered this bug in our code,
[here](https://github.com/deltachat/deltachat-desktop/blob/c860b0f4c659cdb0659ba946ecdd7f0381792946/packages/target-tauri/src-tauri/src/help_window.rs#L34-L43).
@WofWca
WofWca marked this pull request as ready for review March 13, 2025 20:29
@WofWca
WofWca requested a review from a team as a code owner March 13, 2025 20:29
@github-actions

Copy link
Copy Markdown
Contributor

Package Changes Through 50895ee

There are 6 changes which include tauri with minor, @tauri-apps/api with minor, tauri-runtime-wry with minor, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.3.0 2.4.0
tauri-bundler 2.2.4 2.2.5
tauri-runtime-wry 2.4.1 2.5.0
tauri 2.3.1 2.4.0
@tauri-apps/cli 2.3.1 2.3.2
tauri-cli 2.3.1 2.3.2

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@amrbashir
amrbashir merged commit f67a4a6 into tauri-apps:dev Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants