tauri-apps / tauri-apps/plugins-workspace
[bug][plugin-http] Can't fetch containing dots URLs using plugin-http
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
Hi there!
I encountered an issue with @tauri-apps/plugin-http when trying to fetch a URL that contains dots in the path. For example, attempting a fetch on the URL http://localhost:8080/abc.test/test.txt results in the following error:
`SyntaxError: The string did not match the expected pattern.`
**Steps to Reproduce:**
1. Set up a simple server (e.g., at http://localhost:8080).
2. Attempt to fetch a resource with a URL containing dots in the path, like http://localhost:8080/abc.test/test.txt.
```ts
fetch("http://localhost:8080/abc.test/test.txt");
```
3. Observe that the fetch fails with the mentioned error.
**Additional Observations:**
- If I modify the URL to replace the dot with another character, for example, abc-test, the fetch works correctly.
- This behavior seems specific to URLs containing dots in the url path
- The JS log is not very detailed; it simply stops at `SyntaxError: The string did not match the expected pattern.` without a detailed stack trace. The last point of the stack stops right at the fetch function with no further details.
**Attempts done**
- Tried using `encodeURI` and `encodeURIComponent` of the URL, but it actually made the situation worse.
**Tauri Info:**
```sh
$ tauri info
[✔] Environment
- OS: Mac OS 15.1.1 arm64 (X64)
✔ Xcode Command Line Tools: installed
✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
✔ rustup: 1.27.1 (2024-04-24)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 21.5.0
- pnpm: 9.6.0
- yarn: 1.22.22
- npm: 10.2.4
[-] Packages
- tauri :crab:: 2.1.1
- tauri-build :crab:: 2.0.3
- wry :crab:: 0.47.2
- tao :crab:: 0.30.8
- @tauri-apps/api : 2.1.1
- @tauri-apps/cli : 2.1.0
[-] Plugins
- tauri-plugin-deep-link :crab:: 2.0.1
- @tauri-apps/plugin-deep-link : 2.0.0
- tauri-plugin-fs :crab:: 2.0.3
- @tauri-apps/plugin-fs : not installed!
- tauri-plugin-http :crab:: 2.0.3
- @tauri-apps/plugin-http : 2.0.1
- tauri-plugin-shell :crab:: 2.0.2
- @tauri-apps/plugin-shell : 2.0.1
- tauri-plugin-single-instance :crab:: 2.0.1
- @tauri-apps/plugin-single-instance : not installed!
[-] App
- build-type: bundle
- CSP: default-src 'self'; connect-src ipc: http://ipc.localhost
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: React
- bundler: Vite
```
Is this a known issue with the @tauri-apps/plugin-http package? Are there any workarounds or fixes for this behavior?
Thank you for your help!
Contributor guide
Assessment
This issue has not been assessed yet.