Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Cannot use URL parameters with window.location.href #8148

Closed
brendanosborne opened this issue Oct 31, 2023 · 3 comments
Closed

[bug] Cannot use URL parameters with window.location.href #8148

brendanosborne opened this issue Oct 31, 2023 · 3 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@brendanosborne
Copy link

Describe the bug

I am unable to use URL parameters with window.location.href

This works:
window.location.href = 'test.html'

But this doesn't work:
window.location.href = 'test.html?test=test'

The console outputs "Navigated to http://127.0.0.1:1430/test.html?test=test" but the page does not change.

I am using plain HTML with no build tools or frameworks. I have also tried using the following but it returns the same result:

window.location.href = encodeURIComponent(test.html?test=test, 'UTF-8')})

Reproduction

I was able to reproduce the problem in a freshly created Tauri HTML app.

Expected behavior

It should route to test.html and the URL params should be available in the test.html page.

Platform and versions

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 118.0.2088.76
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.72.0 (5680fa18f 2023-08-23)
    ✔ cargo: 1.72.0 (103a7ff2e 2023-08-15)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)  
    - node: 18.18.0
    - yarn: 1.22.19
    - npm: 10.1.0

[-] Packages
    - tauri [RUST]: 1.5.2
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.5
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 1.5.6

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../src
    - devPath: ../src

Stack trace

No response

Additional context

No response

@brendanosborne brendanosborne added status: needs triage This issue needs to triage, applied to new issues type: bug labels Oct 31, 2023
@1mZ1kk4d0
Copy link

Managed to solve? I have the same problem, but instead of staying on the same page it sends it to the home page.

@damooo
Copy link

damooo commented Jan 28, 2024

Indeed. Same problem. It routes to home page. I had to use uri hash instead.

amrbashir added a commit that referenced this issue Jan 29, 2024
* fix(cli): Ignore query parameter in dev server

fixes #8148
additional ref: https://discord.com/channels/616186924390023171/1201199918379974766

* Update .changes/cli-devserver-queryparam.md

---------

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
@1mZ1kk4d0
Copy link

@damooo the recommendation was to use localStorage to save the information, however this occurs in DEV mode in build and it works normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

4 participants